Files
Server-scripts/quiethost/find_panorama.sh
T
2026-09-14 12:43:38 +02:00

32 lines
860 B
Bash
Executable File

#!/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