Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
I'm using ImageMagick for a PHP-website. It works fantastic But I can't seem to get PNG-compression working, even after a lot of tries with lots of different compression quality numbers.
This is what I'm using:
ImageMagick 6.9.6-4 Q16 amd64 (2016-12-19)
imagick 3.4.1
PHP 7.0.14
In GIMP when saving a PNG I can choose between compression level 0 (no compression) to 9 (best compression).
Can anybody help me on my way to use compression level '9' (like GIMP) using PHP's imagick?
I know there are 2 digits for specifying the compression level with setImageCompressionQuality. I've also read this on StackOverflow: http://stackoverflow.com/a/26997997
(and other stuff)
Thanks! But for some reason no matter what quality setting I choose, the size remains exactly the same I've noticed. I must be doing something completely wrong?
Maybe I should be doing things in some other order. And if necessary, which value would I need to set for setImageCompression?
I'm doing something like this, in specified order:
stripImage() // to strip metadata
setImageCompression(\Imagick::COMPRESSION_UNDEFINED) // also tried other values
setImageCompressionQuality(90) // also tried other values (and also tried setCompressionQuality instead)
setImageFormat('png')
scaleImage(...)
writeImage(...)
Update:
Also tried to put setImageFormat before the setImageCompression-line. Size still remains the same.
Last edited by Humanoid on 2017-01-21T13:30:42-07:00, edited 1 time in total.
Edit:
Corrected a mistake and ran the code again. The original PNG image is 203 KB. The smallest file with compression is 212 KB and the biggest file with compression is 319 KB.
Edit 2:
Sorry, original size seems to be 227 KB, so it *does* compress: . Sorry!