DSL Tips and Tricks :: Tip for digital camera owners



If you have a directory full of big digital camera images, here's one way to batch recompress these down to a more manageable size for storage.

Suppose for argument's sake you have a mixture of pics in there and only want to recompress those from your FURTLEWANG camera

1. Load jhead.uci, imagemagick.uci and gnu-utils.dsl

2.  Back up your images first

cp -a image-dir image-dir.bak

3. cd image-dir

4.
Code Sample

 find -type f -name '*' -size +2048k -print0  2>/dev/null | xargs -0 jhead -exonly -model FURTLEWANG -cmd "/opt/imagemagick/bin/mogrify -quality 80 &i"


This will find jpegs from your camera over 2MB size (change the size switch on 'find' to suit yourself) and recompress at 80% quality. Or lower if you want, to get smaller images.  Experiment to see if you can detect any difference.  This is lossy so only do it once.

You can then reduce the size a bit further if you wish by loading stegdetect_i686.uci (which happens to contain the jpeg utils as dependencies) and running:

Code Sample

jpegtran -progressive somepic.jpg >somepic_prog.jpg


This will need to be put in a loop to do a batch; the batch instructions in the jhead docs don't seem to work with this jpegtran.

make jpegtran also use -optimize, it takes a little more time but produces smaller images..

original here.