@@ -120,7 +120,7 @@ class Image
120120
121121 public const EMPTY_GIF = "GIF89a \x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00! \xf9\x04\x01\x00\x00\x00\x00, \x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D \x01\x00; " ;
122122
123- private const FORMATS = [self ::JPEG => 'jpeg ' , self ::PNG => 'png ' , self ::GIF => 'gif ' , self ::WEBP => 'webp ' , self ::BMP => 'bmp ' ];
123+ public const EXTENSIONS = [self ::JPEG => 'jpg ' , self ::PNG => 'png ' , self ::GIF => 'gif ' , self ::WEBP => 'webp ' , self ::BMP => 'bmp ' ];
124124
125125 /** @var resource */
126126 private $ image ;
@@ -153,7 +153,7 @@ public static function fromFile(string $file, int &$detectedFormat = null)
153153 }
154154
155155 $ detectedFormat = @getimagesize ($ file )[2 ]; // @ - files smaller than 12 bytes causes read error
156- if (!isset (self ::FORMATS [$ detectedFormat ])) {
156+ if (!isset (self ::EXTENSIONS [$ detectedFormat ])) {
157157 $ detectedFormat = null ;
158158 throw new UnknownImageFileException (is_file ($ file ) ? "Unknown type of file ' $ file'. " : "File ' $ file' not found. " );
159159 }
@@ -176,7 +176,7 @@ public static function fromString(string $s, int &$detectedFormat = null)
176176
177177 if (func_num_args () > 1 ) {
178178 $ tmp = @getimagesizefromstring ($ s )[2 ]; // @ - strings smaller than 12 bytes causes read error
179- $ detectedFormat = isset (self ::FORMATS [$ tmp ]) ? $ tmp : null ;
179+ $ detectedFormat = isset (self ::EXTENSIONS [$ tmp ]) ? $ tmp : null ;
180180 }
181181
182182 return new static (Callback::invokeSafe ('imagecreatefromstring ' , [$ s ], function (string $ message ): void {
@@ -490,7 +490,7 @@ public function place(self $image, $left = 0, $top = 0, int $opacity = 100)
490490 public function save (string $ file , int $ quality = null , int $ type = null ): void
491491 {
492492 if ($ type === null ) {
493- $ extensions = array_flip (self ::FORMATS ) + ['jpg ' => self ::JPEG ];
493+ $ extensions = array_flip (self ::EXTENSIONS ) + ['jpeg ' => self ::JPEG ];
494494 $ ext = strtolower (pathinfo ($ file , PATHINFO_EXTENSION ));
495495 if (!isset ($ extensions [$ ext ])) {
496496 throw new Nette \InvalidArgumentException ("Unsupported file extension ' $ ext'. " );
@@ -536,7 +536,7 @@ public function __toString(): string
536536 */
537537 public function send (int $ type = self ::JPEG , int $ quality = null ): void
538538 {
539- if (!isset (self ::FORMATS [$ type ])) {
539+ if (!isset (self ::EXTENSIONS [$ type ])) {
540540 throw new Nette \InvalidArgumentException ("Unsupported image type ' $ type'. " );
541541 }
542542 header ('Content-Type: ' . image_type_to_mime_type ($ type ));
0 commit comments