@@ -33,11 +33,6 @@ public function createDataUriThumbnail(string $filename, int $width, int $height
33
33
// Resize and encode
34
34
$ encoded = $ this ->encode ($ filename , $ encodingWidth , $ encodingHeight );
35
35
36
- if ($ encoded instanceof \Exception) {
37
- // Return 1 x 1 pixel transparent PNG
38
- return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII= ' ;
39
- }
40
-
41
36
// Create a new blurred thumbnail from encoded BlurHash
42
37
$ pixels = \kornrunner \Blurhash \Blurhash::decode ($ encoded , $ width , $ height );
43
38
@@ -57,31 +52,28 @@ public function encode(string $filename, int $encodingWidth = 75, int $encodingH
57
52
throw new \LogicException ("Missing package, to use the \"blur_hash \" Twig function, run: \n\ncomposer require intervention/image " );
58
53
}
59
54
60
- try {
61
- // Resize image to increase encoding performance
62
- $ image = $ this ->imageManager ->make (file_get_contents ($ filename ));
63
- $ image ->resize ($ encodingWidth , $ encodingHeight , static function ($ constraint ) {
64
- $ constraint ->aspectRatio ();
65
- $ constraint ->upsize ();
66
- });
55
+ // Resize image to increase encoding performance
56
+ $ image = $ this ->imageManager ->make (file_get_contents ($ filename ));
57
+ $ image ->resize ($ encodingWidth , $ encodingHeight , static function ($ constraint ) {
58
+ $ constraint ->aspectRatio ();
59
+ $ constraint ->upsize ();
60
+ });
67
61
68
- // Encode using BlurHash
69
- $ width = $ image ->getWidth ();
70
- $ height = $ image ->getHeight ();
62
+ // Encode using BlurHash
63
+ $ width = $ image ->getWidth ();
64
+ $ height = $ image ->getHeight ();
71
65
72
- $ pixels = [];
73
- for ($ y = 0 ; $ y < $ height ; ++$ y ) {
74
- $ row = [];
75
- for ($ x = 0 ; $ x < $ width ; ++$ x ) {
76
- $ color = $ image ->pickColor ($ x , $ y );
77
- $ row [] = [$ color [0 ], $ color [1 ], $ color [2 ]];
78
- }
79
-
80
- $ pixels [] = $ row ;
66
+ $ pixels = [];
67
+ for ($ y = 0 ; $ y < $ height ; ++$ y ) {
68
+ $ row = [];
69
+ for ($ x = 0 ; $ x < $ width ; ++$ x ) {
70
+ $ color = $ image ->pickColor ($ x , $ y );
71
+ $ row [] = [$ color [0 ], $ color [1 ], $ color [2 ]];
81
72
}
82
- return \kornrunner \Blurhash \Blurhash::encode ($ pixels , 4 , 3 );
83
- } catch (\Exception $ e ) {
84
- return $ e ;
85
- }
73
+
74
+ $ pixels [] = $ row ;
75
+ }
76
+
77
+ return \kornrunner \Blurhash \Blurhash::encode ($ pixels , 4 , 3 );
86
78
}
87
79
}
0 commit comments