Simple Animated GIF Problem
Posted: 2009-05-02T20:31:02-07:00
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.
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.