4

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

fmw42
  • 46,825
  • 10
  • 62
  • 80
Vishwesh
  • 108
  • 2
  • 9
  • If each of your slice images has more than 256 colors, then Imagemagick will take a long time to quantize each one to a different set of 256 colors. You might consider use a common color table image and the Imagemagick function -remap to process each to a common set of colors. See https://www.imagemagick.org/Usage/quantize/#remap and use -dither none or +dither. – fmw42 Apr 24 '18 at 06:38
  • Thanks @fmw42. My images have 256 colors only so that should not be a problem. – Vishwesh Apr 25 '18 at 07:52
  • But each gif may have a different set of 256 colors. Perhaps one common set of colors would process faster. – fmw42 Apr 25 '18 at 16:12

1 Answers1

2

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
Ole Tange
  • 31,768
  • 5
  • 86
  • 104
  • 1
    This worked greeate, except in the first step of aggregation ( command with -X ), i have to also had -N50 or something like that, otherwise first processor pretty much take all of the png files. Is there a way to let parallel to have all of process to have approximately equal ammount of files to process? – yosukesabai Oct 24 '20 at 01:39