nette / utils

🛠 Lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.
https://doc.nette.org/utils
Other
1.98k stars 147 forks source link

Image::class and JPG compatible file formats #259

Closed forgie1 closed 3 years ago

forgie1 commented 3 years ago

Version: 3.2.2

Bug Description

Image::save('image-file.jfif', 90) throws Nette\InvalidArgumentException

Expected Behavior

a) properly save the image, since it is jpg compatible format b) throw UnknownImageFileException not a InvalidArgumentException

Possible Solution

change this row: https://github.com/nette/utils/blob/v3.2.2/src/Utils/Image.php#L566 to: $extensions = array_flip(self::FORMATS) + ['jpg' => self::JPEG] + ['jfif' => self::JPEG]; but there are more compatible JPG formats/file extensions supported by browsers: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types not only jpg/jpeg/jfif

dg commented 3 years ago

You can use $image->save('filename.jfif', 90, Image::JPEG) for not quite common suffixes.