If you use dcraw more often, you know that it is quite boring to always have to type those boring long path names and those boring long file names. With some functions and aliases we can easily debore this!

On my pc my photos are stored on a hard disk that is mounted under /media. Ever since I use a digital camera – that started in November 2000 with a Nikon Coolpix 990 – I store my photos like so:

/mount point/hard disk name/fotoos/year/mmmyy

So the photos I took in this month and year of writing (November 2015) are stored here:


(if needed followed by another folder like holidayatsea, dance, music…). To avoid typing all that, I made an alias. Use a text editor to open the hidden file named .bashrc that sits in your home directory (well, at least on Debian/Ubuntu based systems). Then scroll a bit down to the section with aliases and add the following line to it:

alias nov=’cd /media/barra2/fotoos/2015/nov15′

Save this file, open a terminal and type ‘nov’ without quotes and you instantly jump to that location.


Because it’s also boring to type every time a command like…

$ dcraw -w -T -6 DSC_1000.NEF

… it’s handier to make a function that does the same, but we only have to type ‘dc 1000‘ now.

Open again the file .bashrc in a text editor and place the following code somewhere, for example below the alias section.

# dcraw: nef > 16-bit tiff, using camera white balance
dc() {
echo “usage: dc nnnn (eg. dc 1000)”
echo “dcraw DSC_$1.NEF > 16-bit tiff”
dcraw -w -T -6 DSC_$1.NEF
echo “done”

Two things here. First we gave the function the name dc and we use the variable $1. We call this function by its name dc and expand the file name from the number that is received by the variable to its full name. This means that after saving this file, we can open a terminal, navigate to the folder with raw files and simply type ‘dc 1000’.

Combined with the alias above things get simple. To convert the raw file DSC_1000.NEF in the folder /media/barra2/fotoos/2015/nov15 to a 16-bit tiff, it’s enough to open a terminal and type

$ nov
$ dc 1000

Of course you can call the function any way you want – but keep it short because that’s why we are here for!

I don’t have to say that you must change the NEF extension in the code snippet above to the raw extension of your camera brand because I know you’re smart.


In the article about dcraw I used the brightness variable to adapt the brightness levels. This is often needed. It’s easy to add this to our function using a second variable like so.

# dcraw: nef > 16-bit tif, using brightness as extra variable
dcb() {
echo “usage: dcb 0.8 nnnn”
echo “DSC_$2.NEF > 16-bit tiff via dcraw with option -b(rightness) = $1”
dcraw -w -T -6 -b $1 DSC_$2.NEF
echo “done”

Here the value for brightness is stored in the first variable, the base number of the raw file sits in the second. Usage: dcb 0.8 1000 (dcp stands for dcraw + brightness) to reduce the brightness level, or >1 to increase that.

ppm to png

By coincidence I found out that the converted raw looks a little bit more attractive when it is first converted to dcraw’s native ppm format and then converted to png. For the conversion I use another program called, ahum yes, convert, that is part of the open source package ImageMagick. On most if not all Linux machines this is installed by default; for other operating systems, look here.

# dcraw: nef > ppm > png, remove ppm
dcp() {
echo “NEF to 16-bit png (via ppm)”
dcraw -w -6 DSC_$1.NEF
convert DSC_$1.ppm DSC_$1.png
rm DSC_$1.ppm

This takes a little bit longer because of the extra convert command. Usage: dcp 1000 (where dcp stand for dcraw to png).

I’m not going to tell you how to add the brightness option to the last function, because I know you’re smart (I have one, called dcpb).


%d bloggers like this: