Linux Photography

Converting RAW to Jpeg in Linux

Dcraw is an amazing open source app that decodes many RAW formats to a more usable format for computer manipulation. It’s used by many commercial programs including Google’s Picassa!
It outputs pnm files, but with a little command line magic it can be used to convert a directory of RAW files to Jpeg.
Canon cameras produce RAW files with the extension “.cr2” so:

for i in *.cr2; do dcraw -c -a -n -h $i | ppmtojpeg > `basename $i cr2`jpg; echo $i done; done

This produces low quality jpeg images alongside your RAW images which makes it useful when browsing the directory with a file manager that doesn’t understand RAW.
You could have the camera produce the low quality jpeg images but why sacrifice the space on your media card?
It goes without saying that this will work on any UNIX platform that Dcraw supports!

By Donncha

Donncha Ó Caoimh is a software developer at Automattic and WordPress plugin developer. He posts photos at In Photos and can also be found on Twitter.

5 replies on “Converting RAW to Jpeg in Linux”

De Raw a Jpeg a linux….

Quantes vegades ens em trobat amb la necessitat de tenir una versió ‘previa’ de les fotografies que hem fet amb la càmera digital quan disparavem en RAW? Baix línux amb Dcraw i ppmtojpeg és pot aconseguir això de manera força ràpida i solucion…

You should update this article – the args to dcraw have changed and it no longer works. Cheers though 🙂

Yes it works, remove -n option or add a number after n between 100 to 1000, its some noise canceler thingy. Also note that its case sensitive. Mine cr2 files was UPPERCASE and below script worked for me. I also used -v (verbose)

for i in *.CR2; do dcraw -c -a -v $i | ppmtojpeg > `basename $i CR2`jpg; echo $i done; done

Leave a Reply