HTFC Forums

H.T.F.C.

How To Fix Computers





Go Back   HTFC Forums > Hardware Newsgroups > Digital Photo

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1  
Old 04-01-2007, 03:09 PM
bizcotti@gmail.com
Guest
 
Posts: n/a
Default My humble contribution - wrapper script for dcraw (linux)

Hi,

I just finished an afternoon of tweaking a wrapper script which I use
to process my Nikon .NEF files into high quality .jpeg image (which I
later upload to Yahoo photos). Setting my D70s to use NEF files then
batch converting them using dcraw allows me to keep most information
available in master files, while keeping easiy viewable and sharable
jpeg copies. Yet I quickly realized that I was losing the EXIF data
(and I wanted to keep that). After carefully reading David Coffin's
page I found that exiftool was just the thing I needed. So I wrapped
it all up in one script. With it you can batch convert .NEF files to
similarly names jpegs. Just drop it in your path (after installing
dcraw and exiftool).

Usage:

nef2jpeg DSC*.NEF

Will automatically convert all NEF files to similar jpegs in the same
directory. The script follows below. If anyone thinks I should change
the flags I pass to dcraw, let me know.

#!/bin/sh

# nef2jpeg
# Batch converts .NEF file to jpeg in the command line.
# wrapper for dcraw
#
# Typical usage:
# nef2jpeg DSC*.NEF
#
# Allan Peda <allan.peda at yahoo.com>
# preserve timestamp, give image a slightly meaningful name
# save EXIF comments in jpeg comment area

# could grab timestamp this way
# stat dsc_0432.jpeg | sed -e '/^Modi/!d; s/^.*: //; s/ .*//'
which dcraw >/dev/null || {
echo "You do not have dcraw installed."
exit 1
}
which exiftool >/dev/null || {
echo "You do not have exiftool installed."
exit 2
}
if [ $# -lt 1 ]; then
echo "please supply at least one arg"
exit 3
fi

DCRAW="dcraw -w -c "
while [ $# -ge 1 ]
do
OJPEG=$(echo $1| perl -pe 's/\.nef$//i' | tr 'A-Z' 'a-z')'.jpeg'
echo "${DCRAW} $1 | cjpeg > ${OJPEG}"
${DCRAW} $1 | cjpeg > ${OJPEG} || echo " *PROBLEM*"
# transfer EXIF data from the original raw file
exiftool -overwrite_original -TagsFromFile "$1" "${OJPEG}" >/dev/
null
# preserve timestamps as much as possible
# touch -r "$1" "${OJPEG}"
dcraw -z "${OJPEG}"
shift
done

Reply With Quote
Sponsored Links
  #2  
Old 04-01-2007, 03:09 PM
bizcotti@gmail.com
Guest
 
Posts: n/a
Default Re: My humble contribution - wrapper script for dcraw (linux)

My previous post had wrapped content, breaking the script. A "slimmer"
version follows...

#!/bin/sh

# nef2jpeg
# Batch converts .NEF file to jpeg in the command line.
# wrapper for dcraw
#
# Typical usage:
# nef2jpeg DSC*.NEF
#
# Allan Peda <allan.peda at yahoo.com>
# preserve timestamp, give image a slightly meaningful name
# save EXIF comments in jpeg comment area

# could grab timestamp this way
# stat dsc_0432.jpeg | sed -e '/^Modi/!d; s/^.*: //; s/ .*//'
which dcraw >/dev/null || {
echo "You do not have dcraw installed."
exit 1
}
which exiftool >/dev/null || {
echo "You do not have exiftool installed."
exit 2
}
if [ $# -lt 1 ]; then
echo "please supply at least one arg"
exit 3
fi

DCRAW="dcraw -w -c "
while [ $# -ge 1 ]
do
OJPEG=$(echo $1|perl -pe 's/\.nef$//i'|tr 'A-Z' 'a-z')'.jpeg'
echo "${DCRAW} $1 | cjpeg > ${OJPEG}"
${DCRAW} $1 | cjpeg > ${OJPEG} || echo " *PROBLEM ($1)*"
# transfer EXIF data from the original raw file
exiftool -overwrite_original -TagsFromFile \
"$1" "${OJPEG}" >/dev/null
# preserve timestamps as much as possible
# touch -r "$1" "${OJPEG}"
dcraw -z "${OJPEG}"
shift
done


Reply With Quote
Sponsored Links
Fix your Windows Problems - FAST.
FREE Safe Scan Registry Check. Locate & Fix Errors in Minutes!
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT. The time now is 05:27 AM.


Powered by vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
© 2004 - 2007 Web-S-Sense Pty. Ltd. Usenet and forums posts © their respective authors.
Ad Management by RedTyger