X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_bin%2Fexifinfo;fp=usr_bin%2Fexifinfo;h=91a7e9028ff647416751418781e42cad9977b6ee;hb=1b8dcad8b9da618cb6c0e22a762cafb08e262640;hp=0000000000000000000000000000000000000000;hpb=608ca3eeeacd74efa85ad44f5585d1b1b60c8d85;p=grml-scripts-core.git diff --git a/usr_bin/exifinfo b/usr_bin/exifinfo new file mode 100755 index 0000000..91a7e90 --- /dev/null +++ b/usr_bin/exifinfo @@ -0,0 +1,137 @@ +#!/bin/sh +########################################################################## +# Title : exifinfo - print EXIF information of an image file +# Author : Heiner Steven +# 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