Last active
December 12, 2015 02:48
-
-
Save bytespider/4701250 to your computer and use it in GitHub Desktop.
convert file.gif -coalesce -layers OptimizeFrame newfile.gif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file_src = 'file.gif'; | |
$im = new Imagick($file_src); | |
$format = $im->getImageFormat(); | |
if ($format != 'GIF') { | |
// reject | |
} | |
$im = $im->coalesceImages(); // split file into individual images | |
foreach ($im as $frame) { | |
$frame->optimizeImageLayers(); // optimize the image layers | |
} | |
$im = $im->deconstructImages(); | |
$im->writeImages(newfile.gif, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment