@@ -132,10 +132,10 @@ class Image
132132 public static function rgb (int $ red , int $ green , int $ blue , int $ transparency = 0 ): array
133133 {
134134 return [
135- 'red ' => max (0 , min (255 , ( int ) $ red )),
136- 'green ' => max (0 , min (255 , ( int ) $ green )),
137- 'blue ' => max (0 , min (255 , ( int ) $ blue )),
138- 'alpha ' => max (0 , min (127 , ( int ) $ transparency )),
135+ 'red ' => max (0 , min (255 , $ red )),
136+ 'green ' => max (0 , min (255 , $ green )),
137+ 'blue ' => max (0 , min (255 , $ blue )),
138+ 'alpha ' => max (0 , min (127 , $ transparency )),
139139 ];
140140 }
141141
@@ -162,7 +162,7 @@ public static function fromFile(string $file, int &$format = NULL)
162162 $ format = NULL ;
163163 throw new UnknownImageFileException (is_file ($ file ) ? "Unknown type of file ' $ file'. " : "File ' $ file' not found. " );
164164 }
165- return new static (Callback::invokeSafe ('imagecreatefrom ' . self ::$ formats [$ format ], [$ file ], function ($ message ) {
165+ return new static (Callback::invokeSafe ('imagecreatefrom ' . self ::$ formats [$ format ], [$ file ], function (string $ message ) {
166166 throw new ImageException ($ message );
167167 }));
168168 }
@@ -186,7 +186,7 @@ public static function fromString(string $s, int &$format = NULL)
186186 $ format = isset (self ::$ formats [$ tmp ]) ? $ tmp : NULL ;
187187 }
188188
189- return new static (Callback::invokeSafe ('imagecreatefromstring ' , [$ s ], function ($ message ) {
189+ return new static (Callback::invokeSafe ('imagecreatefromstring ' , [$ s ], function (string $ message ) {
190190 throw new ImageException ($ message );
191191 }));
192192 }
@@ -205,14 +205,12 @@ public static function fromBlank(int $width, int $height, array $color = NULL)
205205 throw new Nette \NotSupportedException ('PHP extension GD is not loaded. ' );
206206 }
207207
208- $ width = (int ) $ width ;
209- $ height = (int ) $ height ;
210208 if ($ width < 1 || $ height < 1 ) {
211209 throw new Nette \InvalidArgumentException ('Image width and height must be greater than zero. ' );
212210 }
213211
214212 $ image = imagecreatetruecolor ($ width , $ height );
215- if (is_array ( $ color) ) {
213+ if ($ color ) {
216214 $ color += ['alpha ' => 0 ];
217215 $ color = imagecolorresolvealpha ($ image , $ color ['red ' ], $ color ['green ' ], $ color ['blue ' ], $ color ['alpha ' ]);
218216 imagealphablending ($ image , FALSE );
@@ -457,7 +455,7 @@ public function sharpen()
457455 */
458456 public function place (Image $ image , $ left = 0 , $ top = 0 , int $ opacity = 100 )
459457 {
460- $ opacity = max (0 , min (100 , ( int ) $ opacity ));
458+ $ opacity = max (0 , min (100 , $ opacity ));
461459 if ($ opacity === 0 ) {
462460 return $ this ;
463461 }
@@ -524,18 +522,18 @@ public function save(string $file = NULL, int $quality = NULL, int $type = NULL)
524522
525523 switch ($ type ) {
526524 case self ::JPEG :
527- $ quality = $ quality === NULL ? 85 : max (0 , min (100 , ( int ) $ quality ));
525+ $ quality = $ quality === NULL ? 85 : max (0 , min (100 , $ quality ));
528526 return imagejpeg ($ this ->image , $ file , $ quality );
529527
530528 case self ::PNG :
531- $ quality = $ quality === NULL ? 9 : max (0 , min (9 , ( int ) $ quality ));
529+ $ quality = $ quality === NULL ? 9 : max (0 , min (9 , $ quality ));
532530 return imagepng ($ this ->image , $ file , $ quality );
533531
534532 case self ::GIF :
535533 return imagegif ($ this ->image , $ file );
536534
537535 case self ::WEBP :
538- $ quality = $ quality === NULL ? 80 : max (0 , min (100 , ( int ) $ quality ));
536+ $ quality = $ quality === NULL ? 80 : max (0 , min (100 , $ quality ));
539537 return imagewebp ($ this ->image , $ file , $ quality );
540538
541539 default :
0 commit comments