22
33namespace TraderInteractive \Util ;
44
5+ use TraderInteractive \Util ;
6+
57final class Image
68{
79 /**
@@ -214,12 +216,7 @@ public static function resizeMulti(\Imagick $source, array $boxSizes, array $opt
214216 }
215217
216218 //put image in box
217- $ canvas = new \Imagick ();
218- if ($ canvas ->newImage ($ boxWidth , $ boxHeight , $ color ) !== true ) {
219- //cumbersome to test
220- throw new \Exception ('Imagick::newImage() did not return true ' );//@codeCoverageIgnore
221- }
222-
219+ $ canvas = self ::getBackgroundCanvas ($ clone , $ color , $ boxWidth , $ boxHeight );
223220 if ($ canvas ->compositeImage ($ clone , \Imagick::COMPOSITE_ATOP , $ targetX , $ targetY ) !== true ) {
224221 //cumbersome to test
225222 throw new \Exception ('Imagick::compositeImage() did not return true ' );//@codeCoverageIgnore
@@ -234,6 +231,21 @@ public static function resizeMulti(\Imagick $source, array $boxSizes, array $opt
234231 return $ results ;
235232 }
236233
234+ private static function getBackgroundCanvas (\Imagick $ source , string $ color , int $ boxWidth , $ boxHeight )
235+ {
236+ if ($ color === 'blur ' ) {
237+ $ canvas = new \Imagick ();
238+ $ canvas ->readImageBlob ($ source ->getImageBlob ());
239+ $ canvas ->resizeImage ($ boxWidth , $ boxHeight , \Imagick::FILTER_BOX , 15.0 , false );
240+ return $ canvas ;
241+ }
242+
243+ $ canvas = new \Imagick ();
244+ $ imageCreated = $ canvas ->newImage ($ boxWidth , $ boxHeight , $ color );
245+ Util::ensure (true , $ imageCreated , 'Imagick::newImage() did not return true ' );
246+ return $ canvas ;
247+ }
248+
237249 /**
238250 * write $source to $destPath with $options applied
239251 *
0 commit comments