开发者

PHP crop animated gif

开发者 https://www.devze.com 2023-01-20 14:56 出处:网络
Is it possible somehow to crop animated gif with built开发者_运维知识库in php libraries, ie without using Imagick etc?

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消