Sunday, June 29, 2008

How to convert raw to png image files

For most of you this is solved using RawStudio:
sudo apt-get install rawstudio

You run it from Applications > Graphics > Rawstudio, open your directory with the raw files, select them then go to the menu Batch > Add to batch queue
Then click on the "Batch" tab (on the right of the program). Choose the settings you want (no need to change the filename though).

There was a fellow at ubuntuforums with a Fuji camera that couldn't convert the raw (.RAF) images.
I provided the following solution:
sudo apt-get install ufraw
ufraw-batch --help


ufraw can be used for multiple batch processing of raw images.

outputdir="./converted/"
outputsize="640x480"
thumbnailsize="100x75"

[ -d $outputdir ] || mkdir $outputdir
list=`ls -1 | grep -i "\.raf$"`
for i in $list; do
fname=`basename $i | sed -e 's/\.raf$//i'`
outputfile="$outputdir$fname.png"
thumbfile="$outputdir$fname.thumb.png"
ufraw-batch --overwrite --silent --out-type=png16 --size=$outputsize --output=$outputfile "$i"
ufraw-batch --overwrite --silent --out-type=png16 --size=$thumbnailsize --output=$thumbfile "$i"
echo "Done $i"
done

3 comments:

stavros said...
This comment has been removed by the author.
stavros said...

I would really like to see the reason behind the choice of PNG rather than JPEG for the pictures.

Other than that, there is also the GIMP plugin gimp-ufraw which can be used to open RAW images directly on gimp (through ufraw of course)

Unknown said...

No special reason, but read here: http://en.wikipedia.org/wiki/Portable_Network_Graphics#Comparison_with_JPEG

You can change it to use jpeg of course:
...
outputfile="$outputdir$fname.jpg"
thumbfile="$outputdir$fname.thumb.jpg"
...
ufraw-batch --overwrite --silent --out-type=jpeg --size=$outputsize --output=$outputfile "$i"
ufraw-batch --overwrite --silent --out-type=jpeg --size=$thumbnailsize --output=$thumbfile "$i"
...


I know about gimp-ufraw;
I already knew bash,sed,grep to do the trick, I didn't want to start learning the gimp batch processing commands for an easy task such as this one :)
(Maybe in the future)