Convert raw images to displayable formats
The RAW .CR2 pictures are on your disk. You can use the following tools on Linux to manipulate them:
- Fspot: can integrate and display raw pictures, but they can’t be edited. Uses the thumbnail settings embedded in the raw format to decide how to render the picture.
- dcraw: command line tool to do various operations on raw images. Useful tool to operate on a batch.
- ufraw: gui application to manipulate raw files, built on top of dcraw. Comes with ufraw-batch as a command line for batch operations.
- Gimp has ufraw and dcraw plugins.
In the end, to post your pics to Flickr or the like, you need to convert them to 8bit jpg. The workflow should be something like:
- Do most color / gamma / brightness processing from the raw file, so that you have as much data & precision as possible. Most raw software allow you to do that.
- Convert the raw picture to 16bit tiff or ppm, which is basically a lossless format that can be easily displayed.
- Convert the 16bit picture to 8bit jpeg for posting on the web. This step can include resizing and sharpening.
If you need “quick and dirty” jpeg, you can use the -e option in dcraw, which extracts the jpeg thumbnail embedded within raw. This is easy, but of course the result if pretty bad compared to the best you can do (precision, colors). You can still use this if you want to quickly preview your pics.
$ dcraw -e *.CR2
CR2 to ppm
To convert to ppm, you can just use dcraw like this:
$ dcraw *.CR2
This should give you all pictures in ppm format, with hopefully, correct settings like white balance and brightness. You can adjust some of the settings through the options. This will give you ppm that are 8bit per color. If you want 16bit (better if you want to do more processing later on) then you can use -4 option, but then no option applies and result will likely be too dark (incorrect gamma).
The best way to convert seems to be Ufraw:
- First you need to find an ICC profile file for your camera. It basically describe how to interpret the data from the sensor, and is needed for correct colors, etc. The cdrom that comes with your camera most likely has icc profiles (Canon includes them), or it can also be found online, there are a couple here. For my Rebel XT, the correct icc is supposedly “6111″
- Start the app and select one of your pictures to process.
- In “WB” tab, make sure the “camera wb” is selected.
- Then, the most important tab is “Color”. There, pick the right input profile for your camera. The most faithful for me is the 6111_N. Click “Use Color Matrix” if you want to saturate the colors (good for fall colors!). Gamma needs to be set to 0.45 and linearity to somewhere between 0.2 and 0.10, to account for gamma difference between camera and screen. The result you see in the preview is what you will get in the end, so tweak it until you are happy with it.
- Now you have the choice: either you process every pic 1 by 1, in which case just save the file to ppm. Or if you want to apply same settings on a bunch of pictures, click on “Options”, and in the “Configuration” tab click “Save”. This will update your .ufrawrc file with the settings you chose.
- open .ufrawrc (in your home dir) with your favorite editor, and make sure that in the icc profile section you have both
- then you can start ufraw-batch on your files, saving to preferred format:
$ ufraw-batch --out-type=ppm16 *.CR2
ppm to jpeg
It is good to keep the 16bit images around, but you have to convert them to jpeg to post them online.
To convert to jpeg, you can use cjpeg:
$ cjpeg -quality 95 img.ppm > img.jpg
If you need to do it on all pictures, it’s easy with a bash loop:
for file in *.ppm; do echo $file; newname=`basename $file .ppm`.jpg; cjpeg -quality 95 $file > $newname; done
Last, you might want to apply some sharpening to your picture. After all, the camera itself usually applies some when converting to jpeg. You can easily do that (and much more) using the convert command from ImageMagick. Create a “sharp” folder in your current directory and do:
$ for file in *.jpg; do convert $file -unsharp 5 sharp/$file; done
The unsharp action is the classic sharpening tool, a radius of 5 and intensity of 0.5 is a good start.
That’s it! you’re done.