Search code examples
imagemagickimagemagick-convertgnu-parallel

Using parallel and Imagemagick to convert images to gif


I have used a python script which generates plots using a data file. Now because of huge amount of data, I am getting images in the range of 5000 and using ImageMagick's convert on a sequential processing is taking a lot of time.

I referred to this question, where GNU Parallel has been used along with ImageMagick. Is it possible to use a similar code for making a gif?

The command for converting images to gif that I am using is:

convert -delay 0.2 -loop 0 slice_VOF2* slice_VOF.gif

Thanks in advance

Vishwesh


Solution

  • The example you are referring to downscales the individual images in parallel. It it probably a good idea to prepare the images, so that they are the right size before converting them into an animgif.

    parallel convert {} -resize 640x480 {.}.png ::: slice_VOF2*jpg
    

    Then you can convert the images in groups into each their own animgif and finally combine these animgifs:

    ls slice_VOF2*.png | parallel -X convert {} {#}-animpart.gif
    ls *-animpart.gif | sort -n | parallel -Xj1 convert {} anim.gif