Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 470
Yotam Avatar asked Sep 09 '12 13:09

Yotam


2 Answers

Simple and easy, list your images and sort them:

convert -delay 10 -loop 0 $(ls -1 *.png | sort -V) animated.gif
like image 118
Andrey Portnoy Avatar answered Oct 15 '22 07:10

Andrey Portnoy


Even easier than ls and sort is to use the built-in -v option of ls:

convert -delay 10 -loop 0 `ls -v *.png` animated.gif

with `...` being executed instead of interpreted as string.

like image 38
J. Doe Avatar answered Oct 15 '22 07:10

J. Doe