Skip to content

Commit

Permalink
Added check-thumbnail.sh to test thumbnail operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfandrich committed Nov 2, 2018
1 parent 33890f1 commit 08ff692
Show file tree
Hide file tree
Showing 2 changed files with 173 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ EXTRA_DIST = \
check-param-validity.sh \
check-show-description.sh \
check-show-tag.sh \
check-thumbnail.sh \
check-version.sh \
testdata/no-exif.jpg

Expand All @@ -16,6 +17,7 @@ check_SCRIPTS = \
check-param-validity.sh \
check-show-description.sh \
check-show-tag.sh \
check-thumbnail.sh \
check-version.sh

TESTS = $(check_SCRIPTS)
171 changes: 171 additions & 0 deletions test/check-thumbnail.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#!/bin/sh
# Test thumbnail operations

. ./check-vars.sh

tmpfile="check-thumbnail-out.tmp"
tmpimg="check-thumbnail-image.tmp"
tmpimg2="check-thumbnail-image2.tmp"

# Run this in the C locale so the messages are known
LANG=C; export LANG
LANGUAGE=C; export LANGUAGE

echo Create EXIF with thumbnail
cp "$SRCDIR"/testdata/no-exif.jpg "$tmpimg"
# Add image to itself as its own thumbnail
$EXIFEXE --create-exif --insert-thumbnail="$tmpimg" --output="$tmpimg" "$tmpimg" > "$tmpfile" 2>&1
test $? -eq 0 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
Wrote file 'check-thumbnail-image.tmp'.
EOF
test $? -eq 0 || exit 1

echo Check that thumbnail and tags were added
# Strip off date & time
$EXIFEXE --no-fixup "$tmpimg" 2>&1 | sed -e "/Date and Time/s/|.*$/|/" > "$tmpfile"
$DIFFEXE - "$tmpfile" <<EOF
EXIF tags in 'check-thumbnail-image.tmp' ('Motorola' byte order):
--------------------+----------------------------------------------------------
Tag |Value
--------------------+----------------------------------------------------------
X-Resolution |72
Y-Resolution |72
Resolution Unit |Inch
Date and Time |
YCbCr Positioning |Centered
Compression |Internal error (unknown value 0)
X-Resolution |72
Y-Resolution |72
Resolution Unit |Inch
Exif Version |Exif Version 2.1
Components Configura|Y Cb Cr -
FlashPixVersion |FlashPix Version 1.0
Color Space |Uncalibrated
Pixel X Dimension |0
Pixel Y Dimension |0
--------------------+----------------------------------------------------------
EXIF data contains a thumbnail (857 bytes).
EOF
test $? -eq 0 || exit 1

echo Add thumbnail to file that already has a thumbnail
$EXIFEXE --insert-thumbnail=""$SRCDIR"/testdata/no-exif.jpg" --output="$tmpimg2" "$tmpimg" 2>&1 | sed -e "/Date and Time/s/|.*$/|/" > "$tmpfile"
test $? -eq 0 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
EXIF tags in 'check-thumbnail-image.tmp' ('Motorola' byte order):
--------------------+----------------------------------------------------------
Tag |Value
--------------------+----------------------------------------------------------
X-Resolution |72
Y-Resolution |72
Resolution Unit |Inch
Date and Time |
YCbCr Positioning |Centered
Compression |Internal error (unknown value 0)
X-Resolution |72
Y-Resolution |72
Resolution Unit |Inch
Exif Version |Exif Version 2.1
Components Configura|Y Cb Cr -
FlashPixVersion |FlashPix Version 1.0
Color Space |Uncalibrated
Pixel X Dimension |0
Pixel Y Dimension |0
--------------------+----------------------------------------------------------
EXIF data contains a thumbnail (857 bytes).
Wrote file 'check-thumbnail-image2.tmp'.
EOF
test $? -eq 0 || exit 1

echo Extract thumbnail
$EXIFEXE --extract-thumbnail --output="$tmpimg2" "$tmpimg" > "$tmpfile" 2>&1
test $? -eq 0 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
Wrote file 'check-thumbnail-image2.tmp'.
EOF
test $? -eq 0 || exit 1
cmp "$SRCDIR"/testdata/no-exif.jpg "$tmpimg2"
test $? -eq 0 || { echo Thumbnail was corrupted; exit 1; }

echo Remove thumbnail
$EXIFEXE --remove-thumbnail --output="$tmpimg2" "$tmpimg" 2>&1 | sed -e "/Date and Time/s/|.*$/|/" > "$tmpfile"
test $? -eq 0 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
EXIF tags in 'check-thumbnail-image.tmp' ('Motorola' byte order):
--------------------+----------------------------------------------------------
Tag |Value
--------------------+----------------------------------------------------------
X-Resolution |72
Y-Resolution |72
Resolution Unit |Inch
Date and Time |
YCbCr Positioning |Centered
Exif Version |Exif Version 2.1
Components Configura|Y Cb Cr -
FlashPixVersion |FlashPix Version 1.0
Color Space |Uncalibrated
Pixel X Dimension |0
Pixel Y Dimension |0
--------------------+----------------------------------------------------------
Wrote file 'check-thumbnail-image2.tmp'.
EOF
test $? -eq 0 || exit 1

echo Check that thumbnail and tags were removed
$EXIFEXE --no-fixup "$tmpimg2" 2>&1 | sed -e "/Date and Time/s/|.*$/|/" > "$tmpfile"
$DIFFEXE - "$tmpfile" <<EOF
EXIF tags in 'check-thumbnail-image2.tmp' ('Motorola' byte order):
--------------------+----------------------------------------------------------
Tag |Value
--------------------+----------------------------------------------------------
X-Resolution |72
Y-Resolution |72
Resolution Unit |Inch
Date and Time |
YCbCr Positioning |Centered
Exif Version |Exif Version 2.1
Components Configura|Y Cb Cr -
FlashPixVersion |FlashPix Version 1.0
Color Space |Uncalibrated
Pixel X Dimension |0
Pixel Y Dimension |0
--------------------+----------------------------------------------------------
EOF
test $? -eq 0 || exit 1

echo Remove thumbnail on file without thumbnail
$EXIFEXE --remove-thumbnail --output="$tmpimg" "$tmpimg2" 2>&1 | sed -e "/Date and Time/s/|.*$/|/" > "$tmpfile"
test $? -eq 0 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
EXIF tags in 'check-thumbnail-image2.tmp' ('Motorola' byte order):
--------------------+----------------------------------------------------------
Tag |Value
--------------------+----------------------------------------------------------
X-Resolution |72
Y-Resolution |72
Resolution Unit |Inch
Date and Time |
YCbCr Positioning |Centered
Exif Version |Exif Version 2.1
Components Configura|Y Cb Cr -
FlashPixVersion |FlashPix Version 1.0
Color Space |Uncalibrated
Pixel X Dimension |0
Pixel Y Dimension |0
--------------------+----------------------------------------------------------
Wrote file 'check-thumbnail-image.tmp'.
EOF
test $? -eq 0 || exit 1

echo Check adding nonexistent thumbnail
$EXIFEXE --insert-thumbnail="does-not-exist" --output="$tmpimg2" "$tmpimg" > "$tmpfile" 2>&1
test $? -eq 1 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
Could not open 'does-not-exist' (No such file or directory)!
EOF
test $? -eq 0 || exit 1

# Cleanup
echo PASSED
rm -f "$tmpfile" "$tmpimg" "$tmpimg2"

0 comments on commit 08ff692

Please sign in to comment.