Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick convert and GNU parallel together

I would like to speed up the following command:

convert -limit memory 64 -limit map 128 -antialias -delay 1x2 final/*.png movie.mp4

I have seen other blog posts where parallel and convert were used together so I am wondering how to make it work with the command above.

like image 795
aeupinhere Avatar asked Oct 02 '14 20:10

aeupinhere


1 Answers

If downsizing is an option, yes, you can readily do that with GNU Parallel

parallel -j 8 convert {} -resize ... {} ::: *.png

where {} stands for the filename, and the files to be processed are listed after the :::.

-j gives the number of jobs to run in parallel.

I just created 100 PNGs of 10,000 x 8,000 and resized them to 2,000 x 1,200 sequentially in 8 minutes using

#!/bin/bash
for f in *.png; do
    convert $f -resize 2000x1200! $f
done

then, the same original images again, but with GNU Parallel

parallel convert {} -resize 2000x1200! {} ::: *.png

and it took 3 minutes 40 seconds. Subsequently making those 100 PNGs into a movie took 52 seconds.

like image 198
Mark Setchell Avatar answered Oct 19 '22 03:10

Mark Setchell