I just figured out another nifty feature! The D70 has two USB connection modes, “mass storage” where the camera pretends to be an external hard drive, and PTP, which is an industry standard camera-computer USB protocol. Using PTP, it does not seem possible to download the camera contents with gphoto2, as I had with my A80, but it does support the –capture-image function, which causes the trigger release to be released!
(more…)
Tags: capture, gphoto2, Nikon, remote
Posted by Hans-Henry Jakobsen
The fact that most digital cameras store the shooting dates inside JPEG files in the EXIF format makes it possible to automatically archive the photos by date right after they are downloaded, which is exactly what the scripts below do.
Here’s an example of a directory tree they create:
1999
1999-07
1999-07-14
IMG_48324.JPG
IMG_48325.JPG
IMG_48326.JPG
1999-07-17
IMG_48331.JPG
IMG_48333.JPG
IMG_48334.JPG
IMG_48337.JPG
...etc...
move-digiphotos
This bash script (move-digifotos) scans EXIF tags from .JPG files in current directory with metacam, creates necessary directories under $BASEDIR and moves the files in them:
#!/bin/bash # Reads EXIF creation date from all .JPG files in the # current direcotry and moves them carefully under # # $BASEDIR/YYYY/YYYY-MM/YYYY-MM-DD/ # # ...where 'carefully' means that it does not overwrite # differing files if they already exist and will not delete # the original file if copying fails for some reason. # # It DOES overwrite identical files in the destination directory # with the ones in current, however. # # This script was originally written and put into # Public Domain by Jarno Elonenin June 2003. # Feel free to do whatever you like with it. BASEDIR=/home/jarno/gfx find -maxdepth 1 -name "*.JPG" | while read x; do DATE=`metacam "$x" | \ egrep "^[ \t]*Image Capture Date:" | \ sed -r "s/Image Capture Date: ([0-9:]*).*/\1/"` if [ ! -z "$DATE" ]; then YEAR=`echo $DATE | sed -r "s/([0-9]*):([0-9]*):([0-9]*)/\\1/"` MONTH=`echo $DATE | sed -r "s/([0-9]*):([0-9]*):([0-9]*)/\\2/"` DAY=`echo $DATE | sed -r "s/([0-9]*):([0-9]*):([0-9]*)/\\3/"` if [ "$YEAR" -gt 0 ] & [ "$MONTH" -gt 0 ] & [ "$DAY" -gt 0 ] then INSTDIR=${BASEDIR}/${YEAR}/${YEAR}-${MONTH}/${YEAR}-${MONTH}-${DAY} install -d "$INSTDIR" INSTFILE="$INSTDIR/$x" if [ -e "$INSTFILE" ] && ! cmp -s "$x" "$INSTFILE" then echo "WARNING: '$INSTFILE' exists already and is different from '$x'." else echo "Moving '$x'" cp "$x" "$INSTFILE" if ! cmp -s "$x" "$INSTFILE" then echo "WARNING: copying failed somehow, will not delete original '$x'" else rm -f "$x" fi fi else echo "WARNING: '$x' doesn't contain date." fi else echo "WARNING: '$x' doesn't contain date." fi done
fetch-digiphotos
The fetch-digiphotos script fetches pictures from a camera through gphoto2 into a temporary directory under $TMPDIR, moves them with move-digiphotos and finally offers to delete them from the camera:
#!/bin/bash # Downloads pictures from a digital camera using gphoto2, # moves them with move-digiphotos.sh and optionally deletes # them from the camera's memory. # # This script was originally written and put into # Public Domain by Jarno Elonenin June 2003. # Feel free to do whatever you like with it. TMPDIR=/home/jarno/gfx/tmp if [ ! -d "$TMPDIR" ]; then echo "*** Error: download directory '$TMPDIR' does not exist, aborting." exit 1 fi pushd "$TMPDIR" > /dev/null gphoto2 -P if [ $? != 0 ]; then echo "*** error executing gphoto2, aborting." popd > /dev/null exit 1 fi move-digiphotos echo echo -n "Delete pictures from camera? [y/N] " read x if [ $x == "y" ]; then gphoto2 -D fi if [ $? != 0 ]; then echo "Warning: error executing gphoto2." popd > /dev/null exit 1 fi echo "Done." popd > /dev/null
Kilde: Jarno Elonen, 2003-06-17
Tags: bash, egrep, EXIF, find, gphoto2, JPG, sed
Posted by Hans-Henry Jakobsen
1. download photos from camera and sort them by date of day in folders
2. remove possible duplicates if I did not erase camera images since last download
3. convert RAW/NEF images to a usable format
All this in one single click!
#!/bin/bash
# Change this to where to store Photos
target=/home/multimedia/Images
camera=”USB PTP Class Camera”
date=$(date –iso-8601)
mkdir -p $target/$date/tmp
cd $target/$date/tmp
# Get all photos from camera
gphoto2 –quiet –camera $camera –port usb: -P
# Do not replace photos that were already uploaded this same day
cp -u $target/$date/tmp/* $target/$date
rm -rf $target/$date/tmp
cd $target/$date
# auto-rotate using exif info
exifautotran *.JPG
# If photos were not erased from camera since last upload, remove duplicates
for i in *.{JPG,NEF}; do
for f in $(find $target -name $i ! -samefile $target/$date/$i); do
if md5sum $f | sed -e “s, .*/, ,” | md5sum –check; then
rm -f $i;
fi
done
done
# decode RAW images if not already done ?
# for i in *.NEF; do if [ ! -e $(basename $i .NEF).ppm ]; then dcraw -w $i; fi; done
# Show them!
gimv -d $target/$date
Tags: bash, dcraw, EXIF, exifautotran, gimv, gphoto2, JPG, md5sum, NEF, sed
Posted by Hans-Henry Jakobsen