Defining the file order for ImageMagick convert

Yotam picture Yotam · Sep 9, 2012 · Viewed 7.8k times · Source

I have a bunch of PNG files named foo<bar>.png I wish to convert to TIF animation. <bar> is a number varies from 0 to 25 in leaps of five. ImageMagick place foo5.png last in the animation while it is supposed to be second. Is there a way, apart from renaming the file to foo05.png to place it in the right place?

Answer

Kurt Pfeifle picture Kurt Pfeifle · Sep 9, 2012

If you have more input images than are convenient enough to type (say, foo0..foo100.png), you could do this (on Linux, Unix and Mac OS X):

convert                                                  \
  -delay 10                                              \
   $(for i in $(seq 0 5 100); do echo foo${i}.png; done) \
  -loop 0                                                \
   animated.gif