0

I need to convert a large number (~10k) of .xpm files generated by my code to a .gif file.

I used ImageMagick as instructed here: How to convert a PNG strip to a GIF?

But my filenames are like plot*.xpm, * from 0 to 10000 and the convert command doesn't seem to understand it right and makes a .gif file with only a few frames.

My .xpm files are like this

they end somewhere with a non-random distribution of blue and green dots. (Like a circle of blue in the middle) in say 1000th frame. (I can't include it's picture because of posting limits)

But this is the .gif file I get

I use this line of code: convert -loop 0 -delay 10 -page +0+0 /*.xpm output.gif

I think I should use another method to introduce .xpm files to ImageMagick.
What should I do?

Alireza
  • 161

1 Answers1

0

It seems all of your pictures are converted but not in a proper order as you expect.

As per my experience, the convert commands cannot work with files with same filenames format you have used. It works on files with this sort:

file100
file10
file11
file1
file200
file20
file21
file2
...

So, you need to rename all your files before conversion. So, your filenames should become like:

file00001
file00002
...
file00010
...
file10000

This is what I have written. See if using it would solve your problem:

rename 's/plot(\d{1})\.xpm/plot0000$1\.xpm/' *  # plot#.xpm     >    plot0000#.xpm
rename 's/plot(\d{2})\.xpm/plot000$1\.xpm/' *   # plot##.xpm    >    plot000##.xpm
rename 's/plot(\d{3})\.xpm/plot00$1\.xpm/' *    # plot###.xpm   >    plot00###.xpm
rename 's/plot(\d{4})\.xpm/plot0$1\.xpm/' * # plot####.xpm  >    plot0####.xpm

convert -loop 0 -delay 10 *.xpm output.gif