msgbartop
A cronological documentation test project, nothing serious, really!
msgbarbottom

28 May 2007 A EXIF dater script

The script below will take a filename eg: DSCN0001.JPG, extract the “Image Created” metadata and rename the original file to something like 2006-03-23_DSCN00001.JPG and it will do it automatically for you.

#! /bin/shfunction usage() {

if [ $# -ne 1 ]; then
    echo "ExifDater - version 0.1 - March 23 2006"
    echo "El-Lotso ”
    echo “This  is  free  software;  see the source for copying conditions.”
    echo “There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR”
    echo “A PARTICULAR PURPOSE.”
    echo
    echo “ExifDater utilises the exiftags( http://johnst.org/sw/exiftags/)”
    echo “program to sequentially extract the image creation date from”
    echo “JPEG EXIF headers.”
    echo
    echo “Usage:”
    echo “$0 /path/to/jpg/directory”
    exit 0
fi
}

function exiftimexist(){
which exiftime > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo
    echo “Unable to locate exiftime binary”
    echo “Please make sure it is installed and is in your path.”
    echo
    exit 0
fi
}

function gotodir(){
cd $1 > /dev/null 2>&1

if [ $? -ne 0 ]; then
    echo
    echo “Directory does not exists”
    echo “Please try again.”
    echo
    exit 0
fi

}

function jpgexist(){
find . -iname “*.jpg” -type f >/dev/null 2>&1

if [ $? -ne 0 ]; then
    echo
    echo “There are no JPEG pictures in this directory”
    echo “Please try again.”
    echo
    exit 0
fi
}

function myexifdater(){
for i in *.jpg
do
    create_date=`exiftime “$i” 2>&1 | grep -i image created | cut -d” ” -f3 | sed -e ’s/:/-/g’`
    if [ “$create_date” == “” ]; then
        echo -e “SKIPPING IMAGE $i \t\t\t [NO EXIF DATA FOUND]”
        continue
    fi
    echo -n Processing Image $i Created on $create_date
    do_rename=$( echo $i | sed -e ’s/(.*)/mv “&” “‘$create_date’_1″/g’|sh)
    echo -e \t[DONE]

done
}

usage $1
exiftimexist
gotodir $1
jpgexist
myexifdater

Usage: ExifDater /your/picture/path

Download the ExifDater script.

There is also a Windows version of a program that’s called ExifDater for those who need that :)

Source: http://lotso.livejournal.com/2006/03/23/

Tags: , , , ,

Posted by

23 May 2007 Rotate images depending on the EXIF Orientation Tag

Automatic rotation of JPG images (inclusive EXIF thumbnail) can be performed by using jhead.exe and jpegtran.exe in Windows.

jhead -ft -autorot *.JPG

All JPG-files in that folder will be rotated and file time (time and date of exposure) will be set according to the EXIF info.
(more…)

Tags: , , ,

Posted by

18 May 2007 Fikse rett dato på bildefil ut i fra EXIF info

Av og til kopierer man bilder og da kan det hende bildefila får feil dato og tid for når bildet ble tatt. Kjør dette scriptet er for å rette dette igjen
(more…)

Tags: , , ,

Posted by

15 May 2007 Shell scripts for archiving digital photos in directories by date

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 Elonen  in 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 Elonen  in 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: , , , , , ,

Posted by

11 Apr 2007 Organise images using exiftool

Move all files from directory dir into directories named by the original file extensions

exiftool '-Directory<datetimeoriginal>

Rename all images in dir according to the CreateDate date and time, adding a copy number with leading ‘-’ if the file already exists (%-c), and preserving the original file extension (%e).
Note the extra ‘%’ necessary to escape the filename codes (%c and %e) in the date format string.

exiftool '-FileName

Set the filename of all JPG images in the current directory from the CreateDate and FileNumber tags, in the form “20060507_118-1861.jpg”

exiftool '-FileName< ${CreateDate}_$filenumber.jpg' -d %Y%m%d dir/*.jpg

Adjust original date/time of all images in directory dir by subtracting one hour and 30 minutes.

exiftool -DateTimeOriginal-='0:0:0 1:30:0' dir

Tags: ,

Posted by