-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSignManual.sh
executable file
·49 lines (40 loc) · 1.14 KB
/
SignManual.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Sample code for manual signing using ExifTool
Field="$1"
Fname="$2"
if [ "$Fname" == "" ] ; then
echo "Usage: $0 ExiftoolField DestinationFile"
echo " e.g.: $0 -Comment ./test.jpg"
echo " e.g.: $0 -EXIF:seal ./test.jpg"
echo " e.g.: $0 -XMP:seal ./test.jpg"
exit
fi
# grab the file
cp regression/test-unsigned.jpg "$Fname"
# get the record
rec1=$(bin/sealtool -M '')
#echo "Rec1: $rec2"
# insert the record into the file
exiftool -config regression/exiftool-seal.config -overwrite_original "$Field=$rec1" "$Fname" > /dev/null 2>&1
if [ "$?" != "0" ] ; then
echo "ExifTool failure."
exit 1
fi
# get the digest
digest=$(bin/sealtool -v "$Fname" | grep -e '^ *Digest: ' | awk '{print $2}')
#echo "Digest: $digest"
# get the record with the signature
rec2=$(bin/sealtool -M "$digest")
#if [[ "$Field" == *XMP:* ]] ; then
# rec2="${rec2}"
#fi
#echo "Rec2: $rec2"
# re-insert
cp regression/test-unsigned.jpg "$Fname"
exiftool -config regression/exiftool-seal.config -overwrite_original "$Field=$rec2" "$Fname" > /dev/null 2>&1
if [ "$?" != "0" ] ; then
echo "ExifTool update failure."
exit 1
fi
# Now check it
bin/sealtool "$Fname"