Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sort input PNG files in ImageMagick

I am making an animated GIF file using following command:

convert -delay 10 -loop 0 *.png animated.gif

But, the problem happens in the order of *.png.

My PNG files are like 1.png, 2.png, ... 100.png.

In the resulting animated GIF, the order of frames are like: 1.png, 10. png, 100.png, 2.png ...

I want that in the resultant GIF the snapshot are in order like 1,2,3 ... 100.

like image 315
user4914499 Avatar asked Feb 09 '23 19:02

user4914499


1 Answers

Please try sort:

$ ls | sort -V
1.png
2.png
10.png
100.png

So ultimately:

convert -delay 10 -loop 0 $(ls *.png | sort -V) animated.gif
like image 62
NarūnasK Avatar answered Feb 23 '23 16:02

NarūnasK