php.net |  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
Votes:3
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sites at hubmed dot org
New email:
PHP Version: OS:

 

 [2013-02-14 09:37 UTC] sites at hubmed dot org
Description:
------------
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:
---------------
https://gist.github.com/hubgit/4951551



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.


Patches

Pull Requests

History

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] mkoppanen@php.net
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] mkoppanen@php.net
-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] mkoppanen@php.net
Upstream report: http://www.imagemagick.org/discourse-server/viewtopic.php?
f=3&t=24165
 [2013-10-03 06:53 UTC] mkoppanen@php.net
-Status: Feedback +Status: Wont fix
 [2013-10-03 06:53 UTC] mkoppanen@php.net
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:

https://github.com/mkoppanen/imagick/blob/master/tests/022-writeimagefileformat.phpt
 [2013-10-03 14:57 UTC] mkoppanen@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 17:01:31 2024 UTC