Repository navigation
Conversation
| try { | ||
| if ($extension !== '' && in_array(strtoupper($extension), Imagick::queryFormats(), true)) { | ||
| $this->resource->setImageFormat($extension); | ||
| } elseif ($this->image()->imageType !== 0 && ($format = image_type_to_extension($this->image()->imageType, false))) { |
There was a problem hiding this comment.
pls use strict boolean check for $format
| $this->resource->setImageFormat($extension); | ||
|
|
||
| try { | ||
| if ($extension !== '' && in_array(strtoupper($extension), Imagick::queryFormats(), true)) { |
There was a problem hiding this comment.
Imagick::queryFormats() can be assigned to a local variable then reused.
893c05c to
981e676
Compare
michalsn
left a comment
There was a problem hiding this comment.
Could you also update the note under Converting Images? With this change, the ImageMagick handler uses $imageType as a fallback when the target has no extension or an unsupported extension:
When using ImageMagick, a supported target filename extension determines the output format and takes precedence over $imageType. If the target has no extension or an unsupported extension, the handler uses $imageType instead.
Please also update the existing note about save() under Image Quality to mention this fallback, while preserving the guidance about format prefixes and input validation.
981e676 to
7f9cb5f
Compare
Description
ImageMagickHandler::save()unconditionally called$this->resource->setImageFormat($extension)outside of error handling, throwing an uncaughtImagickExceptionwhen saving without an extension or with an unsupported extension (e.g.,.tmp). This change checks againstImagick::queryFormats(), falls back to the current image type format, and wraps the operation in standard image save failure handling.Checklist: