--- /dev/null
+#!/bin/sh
+##########################################################################
+# Title : exifinfo - print EXIF information of an image file
+# Author : Heiner Steven <heiner.steven@odn.de>
+# Date : 2004-01-09
+# Category : Graphics
+# Requires : identify
+# SCCS-Id. : @(#) exifinfo 1.3 04/10/13
+##########################################################################
+# Description
+#
+# Caveats
+# o EXIF tags that would result in invalid shell variable names
+# should be rewritten, e.g. by replacing invalid characters with a
+# '_' character
+# o Individual tag names (e.g. "ImageWidth") should be allowed
+#
+# Bibiliography
+# o exif.org: "Specifications"
+# http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
+# o TsuruZoh Tachibanaya: "Description of Exif file format",
+# http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
+#
+# Output example (identify 5.5.4)
+# EXIF_Make='EASTMAN KODAK COMPANY'
+# EXIF_Model='KODAK DX4530 ZOOM DIGITAL CAMERA'
+# EXIF_Orientation='1'
+# EXIF_XResolution='230/1'
+# EXIF_YResolution='230/1'
+# EXIF_ResolutionUnit='2'
+# EXIF_YCbCrPositioning='1'
+# EXIF_ExifOffset='506'
+# EXIF_ExposureTime='1/30'
+# EXIF_FNumber='28/10'
+# EXIF_ExposureProgram='2'
+# EXIF_ExifVersion='0220'
+# EXIF_DateTimeOriginal='2003:01:03 08:41:52'
+# EXIF_DateTimeDigitized='2003:01:03 08:41:52'
+# EXIF_ComponentsConfiguration='...'
+# EXIF_ShutterSpeedValue='50/10'
+# EXIF_ApertureValue='3/1'
+# EXIF_ExposureBiasValue='0/1000'
+# EXIF_MaxApertureValue='30/10'
+# EXIF_MeteringMode='5'
+# EXIF_LightSource='0'
+# EXIF_Flash='25'
+# EXIF_FocalLength='80/10'
+# EXIF_MakerNote='KDK0002IDX4530 ..'
+# EXIF_FlashPixVersion='0100'
+# EXIF_ColorSpace='1'
+# EXIF_ExifImageWidth='2580'
+# EXIF_ExifImageLength='1932'
+# EXIF_InteroperabilityOffset='2320'
+# EXIF_unknown='R98'
+# EXIF_unknown='0100'
+# EXIF_ExposureIndex='140/1'
+# EXIF_SensingMethod='2'
+# EXIF_FileSource='.'
+# EXIF_SceneType='.'
+# EXIF_unknown='0'
+# EXIF_unknown='0'
+# EXIF_unknown='0'
+# EXIF_unknown='0/100'
+# EXIF_unknown='38'
+# EXIF_unknown='0'
+# EXIF_unknown='1'
+# EXIF_unknown='0'
+# EXIF_unknown='0'
+# EXIF_unknown='0'
+# EXIF_unknown='0'
+##########################################################################
+
+PN=`basename "$0"` # Program name
+VER='1.3'
+
+usage () {
+ echo >&2 "$PN - print EXIF information of an image file, $VER
+usage: $PN [-p prefix] image [image ...]
+ -p: variable prefix (default is \"EXIF_\")
+
+Prints the EXIF information from the image files. The output is printed
+as "var=value" pairs in a way suitable as input to the shell, e.g.
+
+ eval \`$PN image.jpg\`
+
+can be used to set variables e.g. \"EXIF_ExifVersion\". Note that EXIF
+tags with names that would be invalid shell variable names are silently
+ignored."
+ exit 1
+}
+
+msg () {
+ for MsgLine
+ do echo "$PN: $MsgLine" >&2
+ done
+}
+
+fatal () { msg "$@"; exit 1; }
+
+Prefix=
+while getopts :hp: opt
+do
+ case "$opt" in
+ p) Prefix=$OPTARG;;
+ h) usage;;
+ ?) usage;;
+ esac
+done
+shift `expr $OPTIND - 1`
+
+[ $# -lt 1 ] && usage
+
+prefix=${Prefix:-EXIF_}
+info='*'
+
+for file
+do
+ # Explanation of the "sed" expressions:
+ # o remove all lines not containing a "="
+ # o remove "exif:" prefix from identify
+ # o remove all lines containing tag names that would form invalid
+ # shell variable names
+ # o quote all apostrophy characters ' as '\''
+ # o add an apostrophy at the front and the end of the value
+ # string
+ # o write the variable name prefix in front of each variable
+
+ identify -format "%[EXIF:$info]" "$file" |
+ sed \
+ -e '/^[^=]*$/d' \
+ -e 's/^exif://' \
+ -e '/[^A-Za-z0-9_=][^=]*=/d' \
+ -e "s/'/'\\\\''/g" \
+ -e "s/=/='/" \
+ -e "s/\$/'/" \
+ -e "s/^/$prefix/"
+done