go to bug id or search bugs for
When converting a PNG image to JPEG, by using setImageFormat('JPEG'), writing the
file out using writeImage('file.jpg') correctly produces a JPEG file, as does
getImageBlob(), but writeImageFile($resource) produces a PNG file.
writeImageFile produces an image in the format set using setImageFormat.
writeImageFile produces an image in the format that it was originally created as.
Add a Patch
Add a Pull Request
I can confirm this
Imagick 3.0.1 + 3.1.0RC2
ImageMagick ImageMagick 6.6.5-8
This looks like ImageMagick behaviour to me as both of these methods are pretty
thin wrappers. Has this been reported upstream?
I have not reported this upstream.
Upstream report: http://www.imagemagick.org/discourse-server/viewtopic.php?
It looks like this is expected behaviour. For some reason writing the image to a handle uses image filename as the definition for the format. See:
As the behaviour is not quite intuitive I added optional format parameter to writeImageFile call on master: https://github.com/mkoppanen/imagick/blob/master/tests/022-writeimagefileformat.phpt#L46
I am still thinking that it would be better to make writeImageFile to listen setImageFormat but this would break backwards compatibility.