PHP crop animated gif
Is it possible somehow to crop animated gif with built开发者_运维知识库in php libraries, ie without using Imagick etc?
Thanks ;)
There are no "built-in" image processing libraries in PHP. You have to use GD, Imagick, etc.
you can modify my class' resize() method to get your animated gif cropped.
http://www.phpclasses.org/package/7353-PHP-Resize-animations-in-files-of-the-GIF-format.html
The class is resizing GIF animations with GD. First parses the frames, then resizes them, after that it compiles them again into single file without losing its delay times,disposal methods, color tables etc.
This solved my problem to crop GIF using Imagick
$image = new \Imagick('path_to_image');
foreach ($image as $frame) {
$frame->setImageBackgroundColor('white');
$frame->cropImage($width, $height, $x, $y);
$frame->setImagePage($width, $height, 0, 0);
}
$blob = $image->getImageBlob();
精彩评论