How to parallelize this image processing script?

0

I have this script that converts .CR2 images from my Canon camers to Jpegs. The images are named IMG_{NNNN}.CR2 where {NNNN} are the image sequence numbers from the camera. I'd like to parallelize it to use 4 or 8 cores:

#!/bin/sh

for i in `find . -name '*.CR2' | sed 's;./IMG_;;' | sed 's;.CR2;;'`; do dcraw -c -h -w -M -b 1 -o 1 IMG_$i.CR2 | cjpeg -quality 80 > IMG_$i.jpg; done

user2800708

Posted 2016-11-06T17:34:02.640

Reputation: 111

Answers

0

Figure out how many cpus you have by looking at /proc/cpuinfo or some other tool.

Use your command to build a series of batch files, one for each cpu. Then run the batch files with the '&' to run in the background.

Raymond Burkholder

Posted 2016-11-06T17:34:02.640

Reputation: 637