IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
I am using Imagick to resize uploaded images. I have noticed that a large PNG24 I uploaded (2000*2249 pixels at 208kb) increases in size after resizing. The goal of resizing is really to reduce the load on the server
The new values are 1024*910 pixels at 460kb. So for a quarter of the pixels it uses more than double the amount of file space.
I compared this to compression done with photoshop6 and it reduces the image to ~152kb, so something must be going wrong. I assume there are options I have not found yet?
I have tried $im->setCompression (Imagick::COMPRESSION_ZIP) with no change in the result.
I found a solution in the forum (I thought). But it wont work probably because of this:
There seems to be a slight problem with setting image or channel depth. Using Q16, setting the depth to 8 bit, you will have a 16 bit file.
Doesn't matter with better previews / image processing programs. With Win systems the display for TIFF files is a kind of psychedelic art.
This took me hours until I did check with PhotoShop. Besides: even if it works with RGB and PNG files, this consumes resources. Have a look on file size.
Only way out: change to Q8.
IMHO there is no way to run Q8 and Q16 simultaneously.
The above said concerns also setImageDepth.
is there a disadvantage if I use Q8? or does it make more sense anyway for websites?
I will continue to answer my own questions ... I have installed Q8 and the PNG file is now 130kb after resizing. I guess Imagick Q16 has a little bug in the setImageDepth function (in the version I have).
source file: 24-bits per pixel RGB image (each channel 8-bits per pixel)
I use the scale method for resizing images and then I write the image to the disk.
output file: 48-bits per pixel RGB (each channel 8-bits per pixel)
This happens for PNG files. (not JPG files)
If I use setImageDepth(8) then it doesn't change the output depth (still 16). The output PNG files are so big because 16-bit output.
This looks like a bug.
Linux OS
ImageMagick version ImageMagick 6.3.8 01/30/08 Q16
imagick module version 2.0.1
Can you try it with newer version? You can use ./configure --prefix=/opt/imagemagick_new or something similar so it won't mess your current installation.