2024-01-08 20:10:39 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
source .env
|
|
|
|
|
|
|
|
INPUT="${1}"
|
2024-12-08 21:51:53 +00:00
|
|
|
ID="${2}"
|
|
|
|
EXIF="${3}"
|
2024-01-08 20:10:39 +00:00
|
|
|
|
|
|
|
SIZES=(
|
2024-12-09 20:15:27 +00:00
|
|
|
"thumb:420"
|
2024-12-08 21:51:53 +00:00
|
|
|
"full:2000"
|
2024-01-08 20:10:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
function img () {
|
|
|
|
convert "${1}" -colorspace LAB -filter Lanczos -resize ${3}x -strip -quality 86 -colorspace sRGB "${2}"
|
|
|
|
echo "${1} -> ${2}"
|
|
|
|
}
|
|
|
|
|
|
|
|
mkdir -p "${WWW}/img/"
|
|
|
|
mkdir -p "${PHOTOS}/"
|
|
|
|
|
|
|
|
for sizeRaw in ${SIZES[@]}; do
|
|
|
|
sizeName=$(echo $sizeRaw | awk -F':' '{print $1}')
|
|
|
|
size=$(echo $sizeRaw | awk -F':' '{print $2}')
|
|
|
|
name=$(basename "${1}")
|
|
|
|
name=${name%.*}
|
2024-12-09 20:15:27 +00:00
|
|
|
output="${WWW}/img/${ID}_${sizeName}.jpg"
|
2024-01-08 20:10:39 +00:00
|
|
|
img "${1}" "${output}" "${size}"
|
2024-12-11 02:38:41 +00:00
|
|
|
if [[ -f "${WWW}/img/${ID}_${sizeName}-1.jpg" ]]; then
|
|
|
|
mv "${WWW}/img/${ID}_${sizeName}-0.jpg" "${WWW}/img/${ID}_${sizeName}.jpg"
|
|
|
|
rm "${WWW}/img/${ID}_${sizeName}-1.jpg"
|
|
|
|
fi
|
2024-12-03 04:09:32 +00:00
|
|
|
exiftool -overwrite_original -@ "${EXIF}" "${output}"
|
2024-01-08 20:10:39 +00:00
|
|
|
done
|