In my web hosting, I can't use shell, so is there any alternative for this command?
system("convert $src +dither -layers optimize -depth 16 -colors 32 $dest");
I want to compress gif files, so I need to preserve animation.
P.S:
Of course, that I first tried to do it by my own. But without success. So i wrote this question.
Example:
$im = new Imagick("first.gif");
$im->optimizeImageLayers();
$im->writeImages("phpmodul.gif", true);
system("convert first.gif -layers optimize shell.gif");
- first.gif - 649 kB
- phpmodul.gif - 647 kB
- shell.gif - 347 kB
Any help?
P.P.S:
I solved this. My solution.
$animation = new Imagick("$file");
foreach ($animation as $frame) {
$frame->quantizeImage(32, imagick::COLORSPACE_RGB, 16, FALSE, TRUE);
}
$animation = $animation->optimizeImageLayers();
$animation->writeImages("$file", true);