From: Steven Baltakatei Sandoval Date: Sat, 8 Jul 2023 12:11:12 +0000 (+0000) Subject: Merge branch 'master' into develop X-Git-Tag: 0.8.2^0 X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/65207f302c1787df989174cebd4e383ef72eda19?hp=90eca88ef19874660e09705cbd479fd9c145fc01 Merge branch 'master' into develop --- diff --git a/user/bkphotorights b/user/bkphotorights new file mode 100644 index 0000000..608a1e8 --- /dev/null +++ b/user/bkphotorights @@ -0,0 +1,65 @@ +#!/bin/bash +# Desc: Apply metadata to photos +# Usage: bkphotometa.sh [FILE in] +# Ref/Attrib: [1]. Creative Commons XMP recommendation. (2015). https://wiki.creativecommons.org/wiki/XMP +# [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/ +# Version: 0.1.0 +# Depends: exiftool 12.16 (https://exiftool.org/ ) + +# Adjust me +strCreator="Steven Baltakatei Sandoval"; +strCreatorURL="https://baltakatei.com"; +strTerms="This work is licensed to the public under the Creative Commons Attribution-ShareAlike license http://creativecommons.org/licenses/by-sa/4.0/ ."; +strLicenseURL="http://creativecommons.org/licenses/by-sa/4.0/"; + +yell() { echo "$0: $*" >&2; } # print script path and all args to stderr +die() { yell "$*"; exit 111; } # same as yell() but non-zero exit status +must() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails +main() { + declare -a cmd_args; + file_in="$1"; + + # Check plumbing + if [[ ! -f "$1" ]]; then die "FATAL:Not a file:$1"; fi; + if ! command -v exiftool 1>/dev/random 2>&1; then + die "FATAL:exiftool not available. See https://exiftool.org/ ."; fi; + + # Check file + # Check if exiftool recognizes the file format + if ! exiftool -s -FileType "$file_in" 1>/dev/random; then + yell "ERROR:File type not recognized by exiftool:$file_in"; + fi; + + # Change file metadata + unset cmd_args; + cmd_args+=("exiftool"); + # cmd_args+=("-overwrite_original"); # hashtag reckless + + value="$strTerms"; + cmd_args+=("-XMP-dc:Rights=""$value"); unset value; + + value="True"; + cmd_args+=("-XMP-xmpRights:Marked=""$value"); unset value; + + value="$strTerms"; + cmd_args+=("-XMP-xmpRights:UsageTerms=""$value"); unset value; + + value="$strLicenseURL"; + cmd_args+=("-XMP-cc:license=""$value"); unset value; + + value="$strCreator"; + cmd_args+=("-XMP-cc:AttributionName=""$value"); unset value; + + value="$strCreatorURL"; + cmd_args+=("-XMP-cc:AttributionURL=""$value"); unset value; + + cmd_args+=("$file_in"); + + # Execute command + "${cmd_args[@]}"; +}; # main program + +main "$@"; + +# Author: Steven Baltakatei Sandoval +# License: GPLv3+