Reputation: 1784
I have a script that I want to converts images to animated gifs. Alas, they are not in the proper order! Ascending as 10,11,12...19,1,20,21... where I really need it in 1,2,3,4....
#!/bin/bash
for i in `seq 0 22`
do
convert -size 99x99 xc:red -font Palatino-Bold -pointsize 66 \
-fill black -draw "text 20,55 '$i'" $i.png
done
convert -delay 50 -loop *.png output.gif
What should I do to get the gif animated in the correct order?
Upvotes: 2
Views: 607
Reputation: 206567
Another solution:
Sort the files numerically before passing them to convert.
convert -delay 50 -loop $(ls *.png | sort -n) output.gif
Upvotes: 3
Reputation: 798506
Name them properly in the first place.
"$(printf "%02d" "$i").png"
Upvotes: 4