2011
04.02
04.02
You’ll need to install a few packages before this works:
sudo apt-get install netpbm
sudo apt-get install dcraw
sudo apt-get install libimage-exiftool-perl
Once you’ve got these installed, put the following in a file in ~/.gnome2/nautilus-scripts/ and restart Nautilus to add it to the right-click context menu.
#!/bin/bash files=$# count=1 message=`echo "Converting $files RAW files to Jpeg"` (while [ $# -gt 0 ]; do # Strip off the file extension, including the "." upperExt=`echo $1 | sed 's/.*\(\..*\)/\1/' | tr '[a-z]' '[A-Z]'` if [ -f "$1" ] then # Get the file name without the extension trimmed=`echo $1 | sed 's/\(.*\)\..*/\1/'` if [ $upperExt = ".PPM" -o $upperExt = ".CR2" -o $upperExt = ".NEF" -o $upperExt = ".OTHER_RAW_EXTENSION" ] then if [ $upperExt = ".PPM" ] then # Convert the PPM image to a Jpeg pnmtojpeg "$1" > "$trimmed.jpg" else # Convert the RAW image to a Jpeg dcraw -c -w -h -b 1.0 "$1" | pnmtojpeg > "$trimmed.jpg" fi # Copy EXIF data to the new Jpeg image exiftool -overwrite_original -TagsFromFile "$1" "$trimmed.jpg" >/dev/null # Set the Jpeg's file timestamp to match the EXIF date dcraw -z "$trimmed.jpg" fi fi # Output the zenity progress bar sav=`echo "(($count / $files) * 100)" | bc -l` echo $sav count=`expr $count + 1` shift done) | zenity --progress --auto-close --auto-kill --text "$message"
You’ll have to make the file executable by using:
chmod +x raw2jpeg.sh
Update:
I modified the script to convert PPM files created by UFRaw as well. Also now using pnmtojpeg instead of ppmtojpeg.