3

I'm using ImageMagick on Ubuntu Linux and I'm attempting to convert sequentially named files into a gif animation. Usually this is an easy operation and only requires that I run something like convert input-*.png output.gif. However, the filenames don't have leading zeros and so the animation order is something like input-0.png input-10.png input-11.png input-12.png etc. See image below:

enter image description here

I'm aware that I should have used the file padding operator (e.g. intput-03%d.jpg) when creating the files. I'm also aware of variety of methods for adding leading zeros to the files. However, at this time renaming the files would not be feasible.

Is there a way to convert those files using the command line on Linux into a gif with the files animated in the correct order?

  • 2
    It takes less than 3 seconds to add leading zeros to existing file names. I don't understand why that's a hurdle. – Scott Nov 15 '15 at 2:10
  • Like @Scott says: Here is How – joojaa Nov 15 '15 at 6:27
  • If you don't want to rename, you can also create symbolic links in a separate directory having correct names. – sebix Nov 15 '15 at 11:11
  • @Scott that completely depends on how many files there are. – hellocatfood Nov 16 '15 at 0:26
  • 1
    @user5182 uhm.. no it really doesn't. It takes milliseconds to change a file name. So even if there are hundreds or thousands of files, you're looking at a few seconds to let a script run. – Scott Nov 16 '15 at 2:19
2

This answer from the ImageMagick forum solved the problem of combining files into an animation

convert 'image-%d.png[0-20]' output.gif

enter image description here

  • So yeah... you just renamed files as an additional step to the command. Same thing I was eluding to. – Scott Nov 16 '15 at 2:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.