5af038d4044a191a850c930f09eb4f32f225da1e
2 # Desc: Apply metadata to photos with exiftool
3 # Usage: bkphotorights [FILE in]
4 # Ref/Attrib: [1]. Creative Commons XMP recommendation. (2015). https://wiki.creativecommons.org/wiki/XMP
5 # [2]. Eva, Johannes. (2023-03-30). “How to edit EXIF metadata via the command line with ExifTool”. libre-software.net. https://libre-software.net/linux/edit-metadata-exiftool/
6 # [2]. “XMP Tags”. (2023-06-08). exiftool.org. https://exiftool.org/TagNames/XMP.html
8 # Depends: * exiftool 12.16 (https://exiftool.org/ )
10 # Example: bkphotorights DSC00035.JPG
11 # Note: Change strCreator, strCreatorURL, strTerms, and strLicenseURL
12 # values that should be added as metadata to the specified photo.
15 strCreator
="Steven Baltakatei Sandoval";
16 strCreatorURL
="https://baltakatei.com";
17 strTerms
="This work is licensed to the public under the Creative Commons Attribution-ShareAlike license http://creativecommons.org/licenses/by-sa/4.0/ .";
18 strLicenseURL
="http://creativecommons.org/licenses/by-sa/4.0/";
20 yell
() { echo "$0: $*" >&2; } # print script path and all args to stderr
21 die
() { yell
"$*"; exit 111; } # same as yell() but non-zero exit status
22 must
() { "$@" || die
"cannot $*"; } # runs args as command, reports args if command fails
28 if [[ ! -f "$1" ]]; then die
"FATAL:Not a file:$1"; fi;
29 if ! command -v exiftool
1>/dev
/random
2>&1; then
30 die
"FATAL:exiftool not available. See https://exiftool.org/ ."; fi;
33 # Check if exiftool recognizes the file format
34 if ! exiftool
-s -FileType "$file_in" 1>/dev
/random
; then
35 yell
"ERROR:File type not recognized by exiftool:$file_in";
38 # Change file metadata
40 cmd_args
+=("exiftool");
41 # cmd_args+=("-overwrite_original"); # hashtag reckless
44 cmd_args
+=("-XMP-dc:Rights=""$value"); unset value
;
47 cmd_args
+=("-XMP-xmpRights:Marked=""$value"); unset value
;
50 cmd_args
+=("-XMP-xmpRights:UsageTerms=""$value"); unset value
;
52 value
="$strLicenseURL";
53 cmd_args
+=("-XMP-cc:license=""$value"); unset value
;
56 cmd_args
+=("-XMP-cc:AttributionName=""$value"); unset value
;
58 value
="$strCreatorURL";
59 cmd_args
+=("-XMP-cc:AttributionURL=""$value"); unset value
;
61 cmd_args
+=("$file_in");
64 must
"${cmd_args[@]}";
69 # Author: Steven Baltakatei Sandoval