Tuesday November 6, 2007 10:53

Nikon D40x in Ubuntu Linux

Posted by shakir as Information Insemination, Nerd Public Journal?





I’ve been using Nikon D40X on my previous trip to Jakarta (and Bandung). For this I need to update my previous script as there are few differences, as the following:

  • I set the camera to use RAW format rather than jpeg
  • Data transfer is through the laptop’s built in MMC card slot, rather than USB
  • I’m now a (K)Ubuntu user :)

First step, is the software part. As RAW format is not really usable for "presentation", I need to convert it to another format, say JPEG. For this I’m gonna need  ufraw. Let’s install it;

 

sudo apt-get install ufraw
sudo apt-get install gimp-ufraw #optional

 

Using ufraw-batch (included in the ufraw package), I came up with this self explanatory, lightly commented bash script;

 

#!/bin/bash

#Set some variables
MOUNT_DIR=/media/mmc
MOUNT_DEV=/dev/mmcblk0p1
PHOTO_DIR=/home/shakir/Photos/temp/D40X
#Copy files from the MMC card
sudo mkdir $MOUNT_DIR
sudo mount -o uid=shakir,gid=shakir $MOUNT_DEV -t vfat $MOUNT_DIR
mv -v /media/mmc/dcim/100nd40x/* $PHOTO_DIR
sudo umount $MOUNT_DIR
sudo rmdir $MOUNT_DIR
cd $PHOTO_DIR
mkdir jpeg
#Convert RAW files to low quality JPEGs
for i in `ls *.nef`; do
        ufraw-batch –out-type=jpeg –out-path=jpeg/  \
          –compression=70 –size=600,600 –overwrite $i
        mv -v $i nef/
done
mkdir nef
mv *.nef nef/

 

The script would generate a low quality / resolution JPEGs, based on the un-processed RAWs. The JPEGs are useful to actually help me deciding which photos are meant for deletion, and which to keep. Later I would manually go to the selected RAW files folder, and;

ufraw *.nef

to edit the RAW files. This final step would give me the files that I mean to keep;

ufraw-batch --out-type=jpeg --out-path=jpeg/ --compression=100 --overwrite *.nef

I bring back no souvenirs but these photos;







Tags: , , ,



13 Responses to Nikon D40x in Ubuntu Linux

Yoon Kit

November 6th, 2007 at 12:46 pm

These are great pictures!

You sure the “Telnet” wasnt manipulated?

yk.

shakir

November 6th, 2007 at 12:54 pm

The telnet image now links to a closer view of it, which in a way yes, seems manipulated, but not digitally :) . These were taken while I was traveling, in car, so sorry for the quality..

peja

November 7th, 2007 at 6:55 am

Baru balik indon ke bro?..
get news from http://rahard.wordpress.com/2007/11/02/kunjungan-mycert/

shakir

November 7th, 2007 at 7:30 am

Wah Mr Peja, follow blog Pak Budi ke? :)

Yup, was at Indonesia for BCS07, and for the visit too.

chfl4gs_

November 7th, 2007 at 11:39 am

BSD City?!! wow… hahahaha. nice one.

peja

November 8th, 2007 at 9:09 am

Lama dah follow!!..blog Pak Budi Rahardjo sempoii..
amacam cewek2 Bandoeng?..hhaha..I was there (ITB)last year for Nanotech Events & UKM-ITB-LIPI Collaboration

shakir

November 9th, 2007 at 7:48 am

chfl4gs_: Too bad that BSD stands for something that I couldn’t even understand what the taxi driver was explaining, and it’s not at all a geek’s city of some sort :(

peja: Yup, a sempoi one (a rock star too he is, rite? hehe). I just heard ITB is a good place, and we did have drive around the campus while we were there. Too crowded :D

Régis B.

December 27th, 2007 at 7:53 pm

I discovered your blog entry while I was looking for a way to convert my neffiles from my d40x to an “easier” format. After several tests, I realised the output of the ufraw command could be greatly improved by setting the –saturation and –gamma options manually. The results of my experiences is that “–saturation=1.6 –gamma=0.25″ are the parameters that work best, i.e: the output is the closest I could get of the jpeg files that the camera creates when it is set to RAW+low res JPEG.

What do you think?

sudopeople

January 3rd, 2008 at 8:03 am

Your script has helped me out a lot, thanks for sharing.

My thoughts:

Why does it mount your drive? Both the camera and the card itself automount in Dapper+
Why does your script move each .nef in the loop then move all again at the end?
My D40x names the images .NEF on my card not .nef I wonder why yours does them in lowercase…maybe it’s a fat32 filesystem thing with my drive. (I use a Micro SD so I can use my tiny USB card reader)

Thanks again! + I lolled @ your shots

Tiny Card Reader
http://usb.brando.com.hk/prod_detail.php?prod_id=00331

shakir

January 3rd, 2008 at 8:31 am

Régis B.: I’ll look into that and post on it here.
sudopeople: I don’t like automount and so I disabled it :D I’m into improving this post + script and would probably come out with a new post about it..

Linux und das RAW-Format | bernd-distler.net

January 13th, 2008 at 11:33 pm

[...] So schnell kann es gehen. Hier habe ich die Lösung mit ufraw schon gefunden. Einfach das Paket installieren (befindet sich in [...]

Regis B.

January 19th, 2008 at 7:14 pm

I realised the output of ufraw was not close enough with the JPG output of the d40x, whatever the options of ufraw were. After much tattering and testing and googling, the only correct and free solution was to install IrfanView (http://www.irfanview.com/) with the latest plugins installed and to use the program with Wine.
I know, this solution is not really rewarding intellectually speaking, and if you got anything better please let me know.

shakir

January 19th, 2008 at 8:43 pm

@Regis B: I get .ppm files after saving the edited .nef while opening it with ufraw. I later use ppmtojpeg to convert the .ppm to jpeg format. Using ufraw-batch as in my post would give jpegs of unprocessed raw/nef, which surely is nothing not comparable to the JPG output of d40x.. I promised to blog again about this (some fixes, and a functional, interctive script, but then, I’m still trying to squeeze my time for it..

Comment Form