|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64208 writeImageFile does not respect setImageFormat
Submitted: 2013-02-14 09:37 UTC Modified: 2013-10-03 14:57 UTC
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: sites at hubmed dot org Assigned:
Status: Wont fix Package: imagick (PECL)
PHP Version: master-Git-2013-02-14 (Git) OS: Ubuntu
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-02-14 09:37 UTC] sites at hubmed dot org
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.

PHP 5.4.9-4ubuntu1
ImageMagick 6.7.7-10
Imagick 3.1.0RC2

Test script:

Expected result:
writeImageFile produces an image in the format set using setImageFormat.

Actual result:
writeImageFile produces an image in the format that it was originally created as.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-11 20:27 UTC] me at brot-und-spiele dot de
I can confirm this

PHP 5.3.17
Imagick 3.0.1 + 3.1.0RC2
ImageMagick ImageMagick 6.6.5-8
 [2013-09-25 07:43 UTC]
This looks like ImageMagick behaviour to me as both of these methods are pretty 
thin wrappers. Has this been reported upstream?
 [2013-09-25 07:43 UTC]
-Status: Open +Status: Feedback
 [2013-09-29 06:56 UTC] sites at hubmed dot org
I have not reported this upstream.
 [2013-09-29 07:11 UTC]
Upstream report:
 [2013-10-03 06:53 UTC]
-Status: Feedback +Status: Wont fix
 [2013-10-03 06:53 UTC]
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:
 [2013-10-03 14:57 UTC]
As the behaviour is not quite intuitive I added optional format parameter to writeImageFile call on master:

I am still thinking that it would be better to make writeImageFile to listen setImageFormat but this would break backwards compatibility.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Dec 10 09:05:54 2022 UTC