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
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