From 25364cccc7b8a83bc90b6b2439534e81e13d72d3 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Tue, 20 Dec 2022 12:53:04 +0100 Subject: [PATCH] Option to only copy diff image without showing --- diff-image | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/diff-image b/diff-image index 1da14a4..6540c79 100755 --- a/diff-image +++ b/diff-image @@ -2,7 +2,6 @@ set -euo pipefail - usage() { echo "Usage: $0 [] " @@ -16,6 +15,7 @@ usage() echo " 5% for JPEGs, zero otherwise." echo " -n The name to give the first file." echo " -N The name to give the second file." + echo " -o Output pathname to save diff instead of showing it" echo } @@ -26,7 +26,9 @@ exif_only=false fuzz= name1= name2= -while getopts "hb:c:ef:n:N:" opt +outputPath= + +while getopts "hb:c:ef:n:N:o:" opt do case "$opt" in h) @@ -51,6 +53,9 @@ do N) name2="$OPTARG" ;; + o) + outputPath="$OPTARG" + ;; esac done shift $(( OPTIND - 1 )) @@ -237,7 +242,13 @@ then fi do_compare - xdg-open "$destfile" + if [ -n "$outputPath" ] + then + echo "Copy diff image to $outputPath" + cp "$destfile" "$outputPath" + else + xdg-open "$destfile" + fi else w=$(exiftool -p '$ImageWidth' "$f1" || true) if [[ $w -ge 10000 ]] @@ -246,6 +257,12 @@ else exec open "$destfile" "$f2" else do_compare - exec open "$destfile" + if [ -n "$outputPath" ] + then + echo "Copy diff image to $outputPath" + cp "$destfile" "$outputPath" + else + exec open "$destfile" + fi fi fi