How to sort input PNG files in ImageMagick How to sort input PNG files in ImageMagick bash bash

How to sort input PNG files in ImageMagick


Please try sort:

$ ls | sort -V1.png2.png10.png100.png

So ultimately:

convert -delay 10 -loop 0 $(ls *.png | sort -V) animated.gif


This little script will rename your files for you with leading zeroes - try it on a COPY of your files first:

#!/bin/bashfor i in {1..1000}; do   [ -f "$i.jpg" ] && echo mv "$i.jpg" $(printf "%04d.jpg" $i)done

It looks for JPEG files from 1.jpg through 1000.jpg and if any exist, it renames then with up to 3 leading zeroes till the number part is 4 digits wide.

If you save it as renamer, you will then run

chmod +x renamer    # just do this once to make it executable./renamer           # do this any time you want the whole directory of JPEGs renamed

Remove the word echo if you see and like what it is going to do, then run it again.

Sample output

mv 1.jpg 0001.jpgmv 99.jpg 0099.jpgmv 102.jpg 0102.jpg


Rename your images with leading zeroes like:

001.png, 002.png, 003.png,......099.png,100.png.

And it will work fine for you