2 ##########################################################################
3 # Title : exifinfo - print EXIF information of an image file
4 # Author : Heiner Steven <heiner.steven@odn.de>
8 # SCCS-Id. : @(#) exifinfo 1.3 04/10/13
9 ##########################################################################
13 # o EXIF tags that would result in invalid shell variable names
14 # should be rewritten, e.g. by replacing invalid characters with a
16 # o Individual tag names (e.g. "ImageWidth") should be allowed
19 # o exif.org: "Specifications"
20 # http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
21 # o TsuruZoh Tachibanaya: "Description of Exif file format",
22 # http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
24 # Output example (identify 5.5.4)
25 # EXIF_Make='EASTMAN KODAK COMPANY'
26 # EXIF_Model='KODAK DX4530 ZOOM DIGITAL CAMERA'
27 # EXIF_Orientation='1'
28 # EXIF_XResolution='230/1'
29 # EXIF_YResolution='230/1'
30 # EXIF_ResolutionUnit='2'
31 # EXIF_YCbCrPositioning='1'
32 # EXIF_ExifOffset='506'
33 # EXIF_ExposureTime='1/30'
34 # EXIF_FNumber='28/10'
35 # EXIF_ExposureProgram='2'
36 # EXIF_ExifVersion='0220'
37 # EXIF_DateTimeOriginal='2003:01:03 08:41:52'
38 # EXIF_DateTimeDigitized='2003:01:03 08:41:52'
39 # EXIF_ComponentsConfiguration='...'
40 # EXIF_ShutterSpeedValue='50/10'
41 # EXIF_ApertureValue='3/1'
42 # EXIF_ExposureBiasValue='0/1000'
43 # EXIF_MaxApertureValue='30/10'
44 # EXIF_MeteringMode='5'
45 # EXIF_LightSource='0'
47 # EXIF_FocalLength='80/10'
48 # EXIF_MakerNote='KDK0002IDX4530 ..'
49 # EXIF_FlashPixVersion='0100'
51 # EXIF_ExifImageWidth='2580'
52 # EXIF_ExifImageLength='1932'
53 # EXIF_InteroperabilityOffset='2320'
56 # EXIF_ExposureIndex='140/1'
57 # EXIF_SensingMethod='2'
63 # EXIF_unknown='0/100'
71 ##########################################################################
73 PN=`basename "$0"` # Program name
77 echo >&2 "$PN - print EXIF information of an image file, $VER
78 usage: $PN [-p prefix] image [image ...]
79 -p: variable prefix (default is \"EXIF_\")
81 Prints the EXIF information from the image files. The output is printed
82 as "var=value" pairs in a way suitable as input to the shell, e.g.
84 eval \`$PN image.jpg\`
86 can be used to set variables e.g. \"EXIF_ExifVersion\". Note that EXIF
87 tags with names that would be invalid shell variable names are silently
94 do echo "$PN: $MsgLine" >&2
98 fatal () { msg "$@"; exit 1; }
101 while getopts :hp: opt
109 shift `expr $OPTIND - 1`
111 [ $# -lt 1 ] && usage
113 prefix=${Prefix:-EXIF_}
118 # Explanation of the "sed" expressions:
119 # o remove all lines not containing a "="
120 # o remove "exif:" prefix from identify
121 # o remove all lines containing tag names that would form invalid
122 # shell variable names
123 # o quote all apostrophy characters ' as '\''
124 # o add an apostrophy at the front and the end of the value
126 # o write the variable name prefix in front of each variable
128 identify -format "%[EXIF:$info]" "$file" |
132 -e '/[^A-Za-z0-9_=][^=]*=/d' \