New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setImageCompressionQuality isn't doing anything for PNGs #176
Comments
I can confirm the problem with this code (with PHP7, Imagick 3.4.3RC1, ImageMagick 7.0.2):
All quality values (0-99) produce a 474630 byte file. PNG q=5 should skip the zlib compression step, which should produce a much larger file. Using
However, using the other quality setter method works for me:
Now, the q5 png is 754255 bytes. As the q default (in ImageMagick) is 75, q=75 results in the already seen 474630 bytes file. The ImageMagick png coder reads the quality from the Interestingly, this method is not able to set the quality for other image (output) formats such as JPG. Here, q=5 should produce a small file, but it doesn't:
The ImageMagick JPG coder reads the quality directly from the |
Thanks for investigating this, and thanks for pointing out the alternative! Happy to use that instead. |
But I found an effective way, that is use |
Hi @LIXiangChen , I made some test with image compression in a previous thread here: ImageMagick/ImageMagick#29 (comment) Apparently it is $image->setCompressionQuality() that should be used for png images. |
Hi @Danack , Yes, I saw that post. Even though setCompressionQuality() is available, the unavailability of setImageCompressionQuality() is still doesn't make sense. I tend to think that this is a bug. Use setOption() is also good, at least it command is very clear. |
Did you try something like: $image->setImageCompression(Imagick::COMPRESSION_ZIP);
$image->setImageCompressionQuality(5); (basically taken from user comments on http://php.net/manual/en/imagick.setimagecompressionquality.php) |
FTR, this issue had also reported as https://bugs.php.net/77127 which I've now closed as duplicate. Regarding the issue at hand: Imagick::setImageCompressionQuality() is a thin wrapper over MagickSetImageCompressionQuality(), and the quality parameter is clearly documented as
That says it all. ;) |
I'm using Imagick 3.4.1 with ImageMagick 6.9.5-3 (built with mozjpeg). I load a png image in Imagick, fiddle with setImageCompressionQuality and then write it out again but no matter what I set the quality to, the filesize doesn't change. If I run ImageMagick
convert
on the same file, the quality setting works fine. Any idea why this would be? Are there some other options I need to set?The text was updated successfully, but these errors were encountered: