1#!/bin/sh 2# Compares the parsed EXIF data extracted from test images with the parsed EXIF 3# data in the original images. This tests that the tag parsing and writing 4# round-trip produces an EXIF structure with the same meaning as the original. 5srcdir="${srcdir:-.}" 6TMPORIGINAL="$(mktemp)" 7TMPEXTRACTED="$(mktemp)" 8TMPDATA="$(mktemp)" 9trap 'rm -f "${TMPORIGINAL}" "${TMPEXTRACTED}" "${TMPDATA}"' 0 10 11# Remove the file name, which is a harmless difference between the two outputs. 12# Also delete the size of the MakerNote. Since the MakerNote is parsed 13# internally and rewritten, it can sometimes have slightly different padding 14# and therefore slightly different size, which is a semantically meaningless 15# difference. 16# FIXME: Not all MakerNote differences are harmless. For example, 17# olympus_makernote_variant_4.jpg has a huge size difference, probably because 18# of a parsing bug in libexif. This should be investigated. Ideally, this would 19# ignore small differences in size but trigger on larger differences. 20parse_canonicalize () { 21 sed \ 22 -e '/^File /d' \ 23 -e '/MakerNote (Undefined)$/{N;N;d}' 24} 25 26# Ensure that names are untranslated 27LANG= 28LANGUAGE= 29LC_ALL=C 30export LANG LANGUAGE LC_ALL 31for fn in "${srcdir}"/testdata/*.jpg ; do 32 ./test-parse "${fn}" | parse_canonicalize > "${TMPORIGINAL}" 33 ./test-extract -o "${TMPDATA}" "${fn}" 34 ./test-parse "${TMPDATA}" | parse_canonicalize > "${TMPEXTRACTED}" 35 if ! diff "${TMPORIGINAL}" "${TMPEXTRACTED}"; then 36 echo Error parsing "$fn" 37 exit 1 38 fi 39done 40