From: Steven Baltakatei Sandoval Date: Tue, 11 Aug 2026 18:53:33 +0000 (+0000) Subject: feat(user/gthumb/gthumb-analyze.sh):Get stats on selected images X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/aede1736b783eb761899815c74fb1f38a47a8102 feat(user/gthumb/gthumb-analyze.sh):Get stats on selected images --- diff --git a/user/gthumb/gthumb-analyze.sh b/user/gthumb/gthumb-analyze.sh new file mode 100644 index 0000000..430b77d --- /dev/null +++ b/user/gthumb/gthumb-analyze.sh @@ -0,0 +1,140 @@ +#!/bin/bash +# Desc: Analyzes photo files selected in gThumb; shows size/time/GPS +# statistics in a zenity dialog. Intended for evaluating burst-mode +# sequences where larger JPEG size correlates with sharpness. +# Usage: gthumb-analyze.sh FILE… +# Example: $HOME/.local/bin/gthumb-analyze.sh %F +# Depends: bash, GNU coreutils, awk, bc, column (util-linux 2.39.3) +# exiftool (12.x), GNU sed 4.9, zenity +# Version: 0.0.9 + +fdebug=/tmp/gtAnalyzeLog.txt; + +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() { + # Validate inputs + local fina fin cmd; + fina=("$@"); + if [[ $# -le 0 ]]; then die "FATAL:No arguments:$#"; fi; + for fin in "${fina[@]}"; do + if [[ ! -f "$fin" ]]; then die "FATAL:Not a file:${fin}"; fi; + done; + for cmd in awk bc column cut exiftool sed sort zenity; do + command -v "$cmd" >/dev/null 2>&1 || die "FATAL:Missing dependency:${cmd}"; + done; + + # Single batched exiftool pass. Columns (tab-separated): + # col 1: FileName + # col 2: FileSize [bytes] + # col 3: SubSecCreateDate [float POSIX seconds] + # col 4: GPSPosition [±Lat, ±Lon] + # col 5: FNumber [float] + # col 6: ExposureTime [str seconds] + # col 7: ISO [int] + # col 8: FocalLength [str %.01f mm] + # Note: Missing tags emit '-' in -T mode. + local tsv; + tsv="$(exiftool -q -T -FileName '-FileSize#' \ + -SubSecCreateDate -d '%s%f' \ + -GPSPosition -c '%+0.4f' \ + -FNumber -ExposureTime -ISO -FocalLength \ + -- "${fina[@]}")" \ + || die "FATAL:exiftool failed"; + yell "DEBUG:tsv:"; printf '%s\n' "$tsv" 1>&2; + + local n fMax fMaxArr fMin fMinArr mean sdev median span gps; + n="$(printf '%s\n' "$tsv" | wc -l)"; + + # First and last by file name + local fFirst fLast; + fFirst="$(printf '%s\n' "$tsv" | sort -t$'\t' -k1,1 | head -n1 | cut -f1)"; + fLast="$(printf '%s\n' "$tsv" | sort -t$'\t' -k1,1 | tail -n1 | cut -f1)"; + + # Largest and smallest files by size (numeric sort on column 2) + fMax="$(printf '%s\n' "$tsv" | sort -t$'\t' -k2,2n | tail -n1)"; + fMin="$(printf '%s\n' "$tsv" | sort -t$'\t' -k2,2n | head -n1)"; + fMaxArr[0]="$(cut -f1 <<< "$fMax")"; + fMaxArr[1]="$(cut -f2 <<< "$fMax")"; + fMinArr[0]="$(cut -f1 <<< "$fMin")"; + fMinArr[1]="$(cut -f2 <<< "$fMin")"; + ## Avoid & or < being parsed as markup by zenity + fMaxArr[0]="$(sed -e 's/&/\&/g' -e 's/${msg}"; +}; + +main "$@" 1>>"$fdebug" 2>&1; + +# Author: Steven Baltakatei Sandoval +# License: GPLv3+ +