Hello,
I'm using ImageMagick 'system' style commands inside a Perl script. I have successfully taken an animated GIF and broken it into individual frames with IM using something like:
system("/usr/local/bin/convert", "+adjoin", "-coalesce", "orig.gif", "frame_%02d.gif");
As expected, I get the individual frames, i.e. "frame_00.gif", "frame_01.gif", etc.
I then take those individual frames and crop them by looping with a command like:
system("/usr/local/bin/convert", "frame_00.gif", "-crop", "$cropw x $croph + $cropx + $cropy\!", "cframe0.gif");
system("/usr/local/bin/convert", "frame_01.gif", "-crop", "$cropw x $croph + $cropx + $cropy\!", "cframe1.gif");
etc.
This also works, and I get a bunch of cropped frames. These are 320x240 gif images and each will open in image editors and browsers, so I guess they're OK.
Now, I want to re-join the cropped frames into a new animated gif. Here is where I can't seem to get a command working to create the new animated gif. Ive tried (amongst other things) calls like:
system("/usr/local/bin/convert", "-delay 25", "-loop 0", "cframe0.gif", "cframe1.gif", "cframe2.gif", "anim.gif");
and
system("/usr/local/bin/convert", "-delay 25", "-loop 0", "cframe*.gif", "anim.gif");
The "anim.gif" file just isn't created. I'm a total NEWB at this (and surprised I've made it this far), but now I'm stuck. Any help would be appreciated. Thanks.
Simple Animated GIF Problem
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Simple Animated GIF Problem
The "-loop", "0" remember 0 is a separate option argument. Having it as you have it, would be a syntax error (which you probably have in your web servers log)
I would also move -loop 0 to just before the final write seeing that is where it is needed.
As for cropping animations see...
IM examples, Animation Modifications, Cropping (two sections of examples)
http://www.imagemagick.org/Usage/anim_mods/#crop
PS: -coalesce can be very important. See previous sections.
I would also move -loop 0 to just before the final write seeing that is where it is needed.
As for cropping animations see...
IM examples, Animation Modifications, Cropping (two sections of examples)
http://www.imagemagick.org/Usage/anim_mods/#crop
PS: -coalesce can be very important. See previous sections.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Simple Animated GIF Problem
Anthony,
The syntax help and crop example are EXACTLY what I needed. Much appreciated!
The syntax help and crop example are EXACTLY what I needed. Much appreciated!