From ccb079f05c4f52be00da8f64b844b85650f754b9 Mon Sep 17 00:00:00 2001 From: doofus-01 Date: Sun, 27 Oct 2024 10:40:00 -0700 Subject: [PATCH] Update CI to check for XMP rather than EXIF - for PNGs only (#9435) Addresses GIMP metadata editing limitations --- .github/workflows/image_metadata.yml | 34 ++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/workflows/image_metadata.yml b/.github/workflows/image_metadata.yml index 0d755d6de2a..c85a57fc6e5 100644 --- a/.github/workflows/image_metadata.yml +++ b/.github/workflows/image_metadata.yml @@ -27,9 +27,9 @@ jobs: with: fetch-depth: 0 - - name: check image metadata + - name: check image EXIF metadata run: | - mapfile -t image_files < <(git diff --name-only --diff-filter=d "$BASE_SHA" "$HEAD_SHA" | grep -E '\.(webp|png|je?pg)$') + mapfile -t image_files < <(git diff --name-only --diff-filter=d "$BASE_SHA" "$HEAD_SHA" | grep -E '\.(webp|je?pg)$') # cycle through the changed image files, make sure they have the right fields for file in "${image_files[@]}"; do # check Artist tag, fail if missing @@ -56,3 +56,33 @@ jobs: ;; esac done + + - name: check png XMP metadata + run: | + mapfile -t image_files < <(git diff --name-only --diff-filter=d "$BASE_SHA" "$HEAD_SHA" | grep -E '\.png$') + # cycle through the changed image files, make sure they have the right fields + for file in "${image_files[@]}"; do + # check Creator tag, fail if missing + artist="$(exiftool -p '$XMP:Creator' "$file")" + if [ "$artist" ]; then + printf 'Creator tag in %s is %s\n' "$file" "$artist" + else + printf 'no Creator XMP tag in %s\n' "$file" + exit 1 + fi + # check Rights tag, fail if missing or wrong type + copyright="$(exiftool -p '$XMP:Rights' "$file")" + case $copyright in + 'GNU GPL v2+'|'CC BY-SA 4.0'|CC0) + printf 'Rights tag in %s is %s\n' "$file" "$copyright" + ;; + '') + printf 'no Rights XMP tag in %s\n' "$file" + exit 1 + ;; + *) + printf 'Rights tag %s in file %s is not an accepted license! Must be one of: "GNU GPL v2+", "CC BY-SA 4.0", "CC0"\n' "$copyright" "$file" + exit 1 + ;; + esac + done