Ben Imagick
documentation for a while, and tried a couple of things... But I didn't manage to do what you want either -- so, we are at least two who can't find out a clean way ^^ ile devam ettik
Neyse, ben bir animasyonlu GIF görüntü için bir çerçeve kaldırmak için yönetilen tek yolu ben kaldırmak istemedim, sadece çerçeveleri içeren, yeni bir tane oluşturarak oldu :-(
Considering I loaded an image this way :
// Load the existing image
$image = new Imagick(dirname(__FILE__) . '/animated-gif-source.gif');
(This is an animated gif, with 3 frames ; I want to "remove" the second one).
As I said, only way I found to "remove a frame" is this one :
$new_image = new Imagick();
$i = 1;
foreach ($image as $frame) {
if ($i===1 || $i===3) {
// 3 frames ; we keep the first and third one
// ie, remove the second one
$new_image->addImage($frame->getImage());
}
$i++;
}
Yani:
- yeni bir imaj oluşturmak
- orignal birinin kare üzerinde yineleme
- mevcut çerçeve ben tutmak istiyorum biri ise, yeni bir görüntüye kopyalamak
And, in the end, to output the image to the browser :
// To directly output to the browser
header('Content-Type: image/gif');
echo $new_image->getImagesBlob();
Ya da, bir dosyaya yazmak için:
// To write the new image to a file
// Must use writeImages, and not writeImage (multi-frames ! )
$new_image->writeImages(dirname(__FILE__) . '/animated-gif-output.gif', true);
Each one of these outputs only contain the first and third frames ; so, it's working...
But, as you said, it doesn't feel good :-(
It will probably work just fine for most images, I think ; you might encouter troubles with big images, but animated GIFs are generally not that big... are they ?
Other way might be using convert from the command line... But... not that great, and I didn't find a way to just remove a frame with those either :-(