Search code examples
imagemagickimagemagick-convert

Defining the file order for ImageMagick convert


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?


Solution

  • You just give the order of your PNG files as they should appear in the animation. Use:

    foo0.png foo5.png foo10.png foo15.png foo20.png foo25.png
    

    instead of

    foo*.png
    

    After all, it's only 6 different file names which should be easy enough to type:

    convert                                                      \
      -delay 10                                                  \
       foo0.png foo5.png foo10.png foo15.png foo20.png foo25.png \
      -loop 0                                                    \
       animated.gif