How to reduce image sizes in Linux. I have used ImageMagick for this. But it is not working well for gif images. I have used it as:
To resize image
exec("convert $original -resize " . $width . 'x' . $height . ' ' . $destination);
To reduce image size
exec("convert $original -quality 80% $new_img");
Please let me know if you have any way to reduce image size. This code works well for jpg, but not works well for gif images.
Appreciate your help.
Quoting from the Imagemagick manual:
That means that using the quality level will only work on the aforementioned image types, which do not include GIF.
For GIF’s your easiest option is to use the
-colorscommand to reduce the number of colors used in your image. The quality of the result depends very much on what your initial image contains, I have seen cases where a reduction from 256 to 16 colors did not cause significant quality loss, and others where a reduction to 128 colors rendered the image unusable. You’ll have to experiment.A last remark: you could transform your GIF to PNG format and use the
-qualitycommand on the resulting image. Quality on PNG’s however is a bit of a misnomer:So don’t be surprised if the size reduction is less on PNG’s than on JPG’, it only improves compression of the lossless PNG image.