I Imagick through the Imagick documentation for a while and tried a couple of things ... But I'm not "i.e. we are at least two who cannot find the clear path ^^
In any case, the only way to remove the frame for the animated GIF image is to create a new one containing only those frames that I did not want to delete : - (
Given that I uploaded the 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 βdeleteβ the second).
As I said, only one way that I found βdelete frameβ is as follows:
$new_image = new Imagick(); $i = 1; foreach ($image as $frame) { if ($i===1 || $i===3) {
So:
- create new image
- frame iteration orignal
- If the current frame is the one I want to save, copy it to a new image
And finally, to output the image to the browser:
// To directly output to the browser header('Content-Type: image/gif'); echo $new_image->getImagesBlob();
Or, to write it to a file:
// 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 of these outputs contains only the first and third frames; therefore, it works ...
But, as you said, he is not feeling well : - (
I think this will probably work just fine for most images; you may run into problems with large images, but animated GIFs are usually not that big ... are they?
Another way could be to use the conversion from the command line ... But ... not so great, and I did not find a way to just delete the frame using these : - (