Page 1 of 1
Animate images in correct order
Posted: 2015-11-15T15:03:03-07:00
by hellocatfood
I'm using Imagemagick on Ubuntu Linux and I'm attempting to convert sequentially named files into a gif animation. Usually this is an easy operation and only requires that I run something like
. However, the filenames don't have leading zeros and so the animation order is something like input-0.png input-10.png input-11.png input-12.png etc. See image below:
I'm aware that I should have used the file padding operator (e.g. intput-03%d.jpg) when creating the files. I'm also aware of variety of methods for adding leading zeros to the files. However, at this time renaming the files would not be feasible.
Is there a way to convert those files using the command line on Linux into a gif with the files animated in the correct order?
Re: Animate images in correct order
Posted: 2015-11-15T15:49:41-07:00
by fmw42
Why can you not rename the files or convert them into new files with proper alphabetic order. Alternately, you can just list the files in the order you want them to show up in the animation in the convert command
Code: Select all
convert -delay XX image1 image2 image3 ... image10 ... image20 -loop 0 animation.gif
alternately, make a text file listing the images in the order you want and then
Code: Select all
convert -delay xx @file.txt -loop 0 animation.gif
Re: Animate images in correct order
Posted: 2015-11-15T16:14:26-07:00
by hellocatfood
fmw42 wrote:Why can you not rename the files or convert them into new files with proper alphabetic order.
Lots of different sequences in lots of different folders.
I've asked this same question
elsewhere and the (sometimes harsh) answers focus on renaming. I appreciate that this is an option but I want to know if imaegmagick/bash has a way to put the files in the correct order.
Alternately, you can just list the files in the order you want them to show up in the animation in the convert command
Code: Select all
convert -delay XX image1 image2 image3 ... image10 ... image20 -loop 0 animation.gif
Some of the animations have 50/60 frames so it could take a long time to write it out.
alternately, make a text file listing the images in the order you want and then
Code: Select all
convert -delay xx @file.txt -loop 0 animation.gif
Perhaps the best suggestion so far. I thought about using ls or find and piping its output to a text file but both have the same problem of listing files in an "incorrect" order.
Re: Animate images in correct order
Posted: 2015-11-15T16:52:39-07:00
by magick
This seems to work for us:
- convert 'input-%d.png[0-20]' output.gif
Re: Animate images in correct order
Posted: 2015-11-15T17:17:42-07:00
by hellocatfood
magick wrote:This seems to work for us:
- convert 'input-%d.png[0-20]' output.gif
Thank you! That's exactly what I needed.
Re: Animate images in correct order
Posted: 2015-11-15T17:23:33-07:00
by magick
This feature is documented @
http://www.imagemagick.org/script/comma ... essing.php. Tough to find, but there it is.