0

Is it possible somehow to crop animated gif with builtin php libraries, ie without using Imagick etc?

Thanks ;)

Somebody
  • 9,316
  • 26
  • 94
  • 142
  • What do you mean by "built-in"? None of PHP's image functions, (whether from GD or Imagemagick) are "built-in". – user229044 Oct 16 '10 at 17:22
  • Take a look at http://stackoverflow.com/questions/718491/resize-animated-gif-file-without-destroying-animation – Paul Dixon Oct 16 '10 at 17:41

3 Answers3

1

There are no "built-in" image processing libraries in PHP. You have to use GD, Imagick, etc.

Core Xii
  • 6,270
  • 4
  • 31
  • 42
0

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.

Taha Paksu
  • 15,371
  • 2
  • 44
  • 78
  • Hi tpaksu, it would be cool if your class had it built in. Also, I recommend you put your class on Github or Bitbucket or something. That phpclasses.org is crap and you have to register first. – Chris Harrison Feb 23 '13 at 11:46
0

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();
Yoannes Geissler
  • 791
  • 1
  • 9
  • 18