Canon CR2 raw format to JPG conversion script
The exiftools were the missing piece to restart the usage of the RAW format with my Canon 350d. The simple usage of the RAW format without the generation of JPG files within the camera doesn’t fill the storage card quite as fast. My primary reason for using RAW is the storage of all the pictures in a loss-less format and thereby having later the option to process the pictures in 16bit. And of course it’s simpler to fix color issues or to get to the last bit of information in under- or overexposed pictures.
Anyway, so I’ve whipped up this little Perl script, which basically renames the RAW files in a directory or given as an argument into my favorite file name format. Then the pipeline dcraw -w -c <file>.cr2 | convert -quality 90 -unsharp 0.1 ppm:- <file>.jpg is executed, which produces the JPG file. Then exiftool is executed to copy the meta data from the RAW into the JPEG file. Finally exitool is executed again to clear the orientation flag, since dcraw already produces correctly oriented output. The usage() message:
usage:
./cr2tojpg.pl [-force|-output dir|-renameonly|-format pat|-h|-help] [file ...]
-force: force conversation of RAW file into JPG. Without this option,
if the destination file is already present, no conversion is
done.
-output dir: put all generated files into directory dir.
-renameonly: don't do any conversion, only rename the RAW files according
to the file name pattern.
-format pat: Default pattern is '%Y-%m-%d-%H%M%S', which resolves to
something like 2005-10-31-193510.jpg. See manual page for
POSIX function strftime() for possible arguments.
-h|-help: display this usage message
If additional file arguments are given only these files will be converted.
Otherwise all files ending with CR2 or cr2 in the current directory are
converted.
Here is the script. It does the job, but it doesn’t run very fast. It takes about 2 minutes on my 2800+ Athlon XP to convert one picture. As far as I can tell from looking at the top output, the dcraw command burns most of the CPU cycles.
To use this script the ExifTool by Phil Harvey, the ImageMagick toolkit and dcraw must be installed . Standard disclaimer: use at your own risk.
Update: Well, I don’t know how I got the above mentioned 2 minutes for one conversion (looking at the output of an ls -l I guess), but I did a new timing this morning and this resulted in 24 seconds for one conversion. This also includes an update to the latest dcraw version 7.94 and slightly different options to dcraw. My previous version was 7.65. Around version 7.70 there were significant improvements in terms of speed and quality. An update is therefore highly recommended.

