feat(images): consolidate panorama detection

Combine panorama detection utilities into a single script.

- Merge aspect-ratio based panorama detection with dimension-based
checks
- Detect images with aspect ratio < 0.5 or > 1.8
- Detect images where width exceeds three times the height
- Ignore images already tagged as Panorama
- Scan directories recursively for JPG, JPEG, and PNG files
- Add timestamped logging of detected panorama candidates
- Optionally copy detected panoramas to a review directory
- Improve filename handling using find -print0
- Use identify -format for reliable dimension extraction
- Add dependency validation and robust error handling
- Reduce repeated ImageMagick parsing and simplify maintenance
This commit is contained in:
Lucas Vivohost committed 2026-09-14 12:43:38 +02:00
1 parent c1ebc80235
commit 16c69ac7df
3 files changed
+105 -47

No files matched your search

-16
View File
@@ -1,16 +0,0 @@
#!/bin/bash
IFS=$'\n'; set -f
ARR=($(find . \( -name "*.png" -or -name "*.jp*g" \) | grep -v xml))
unset IFS; set +f
for ((i=0;i<${#ARR[@]};i++)); do
NUM1=$(identify "${ARR[i]}" | rev | cut -f7 -d' ' | rev | cut -f1 -d'x')
NUM2=$(identify "${ARR[i]}" | rev | cut -f7 -d' ' | rev | cut -f2 -d'x')
echo "${ARR[i]}"
if [[ "$NUM1" != "" && $NUM2 != "" ]]; then
if [[ $NUM1 -gt $(( $NUM2 * 3 )) ]]; then
identify "${ARR[i]}" >> panoramaImages.txt
cp "${ARR[i]}" /home/lucas/Downloads/
fi
fi
done
-31
View File
@@ -1,31 +0,0 @@
#!/bin/bash
DATE="$(date +'%m%d%H%M%S')"
log="logfile_${DATE}.log"
IMG_DIR="/home/lucas/Pictures/"
PANORAMA_AR_LT="0.5"
PANORAMA_AR_HT="1.8"
> "${IMG_DIR}${log}"
getAspectRatio() {
if [ "$1" == "" ]; then return "0"; fi
identify "$1" | perl -ne '/(.+?)\s+[A-Z]{3,4}\s+(\d+)x(\d+)/; print $3/$2, "\n"'
if [ $? -ne 0 ]; then return "0"; fi
}
write_log() {
echo "$@"
echo "$@" >> "${IMG_DIR}${log}"
}
IFS=$'\n'; set -f
IMG_ARR=($(find ${IMG_DIR} -name '*.jp*g' -or -name '*.JP*G' -name '*.png'))
for IMG in ${IMG_ARR[@]}; do
imageAR=$(getAspectRatio ${IMG})
if [ "${imageAR}" != "" ]; then
if [ $(echo ${imageAR}'<'${PANORAMA_AR_LT} | bc -l) -eq 1 ] || [ $(echo ${imageAR}'>'${PANORAMA_AR_HT} | bc -l) -eq 1 ]; then
if [ $(identify -verbose ${IMG} | grep -o "Panorama" | wc -l) -eq 0 ]; then
write_log ${IMG} ${imageAR}
fi
fi
fi
done