0

I've got a certain number of png files, named 1.png, 2.png, etc. and need to make an animation with them. I'm using convert -delay 20 *.png animation.gif.

The first time I used it, it happened that the animation created started at 10 then 11 then 12, all the way up to 19 and then it goes to 2! It's logical, but I don't want that. So what I did was modify the names to 01.png, 02.png.

That was OK at the beginning. Now, I want to make a gif with more images(thousands), and the problem is that when it goes 10 for example, it goes to 100! I can't be modifying the names manually, because all this is part of a script, and the user chooses how many png he wants. So, how to solve?

3

This is nothing to do with the convert command - your shell is expanding the glob pattern *.png before it is passed to the command, and it does so in the lexical collation order LC_COLLATE defined as part of system's current locale.

Unfortunately it's hard to get numeric ordering in the bash shell (which is what I assume you are using): if you don't mind switching to zsh there is the possibility to use a numeric glob qualifier i.e.

convert -delay 20 *.png(n) animation.gif

For further discussion, see for example this related Q&A Glob with Numerical Order

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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