Was 3 tiers (phone/tablet/desktop at 640/1280/1920px). Renamed the 1920px tier to laptop and added a new desktop tier at 2560px for 5K-iMac-class screens, matching the launcher's own top breakpoint. docs/photo-pipeline.md writes down the whole path from upload (Tailscale or SMB) through resizing to the pictures/<motiv>/<device>/ naming convention, since it wasn't documented anywhere before.
52 lines
1.5 KiB
Bash
Executable file
52 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if [[ $# -lt 1 || $# -gt 3 ]]; then
|
|
echo "Usage: $0 INPUT [BASENAME] [OUTPUT_ROOT]" >&2
|
|
echo "Example: $0 IMG_0944.HEIC ecoteam /var/www/data/external/pictures" >&2
|
|
exit 2
|
|
fi
|
|
|
|
input_path=$1
|
|
image_name=${2:-$(basename "${input_path%.*}")}
|
|
output_root=${3:-/var/www/data/external/pictures}
|
|
|
|
if [[ ! -f "$input_path" ]]; then
|
|
echo "Input file not found: $input_path" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v magick >/dev/null 2>&1; then
|
|
echo "ImageMagick is required: command 'magick' not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$output_root/phone" "$output_root/tablet" "$output_root/laptop" "$output_root/desktop"
|
|
|
|
resize_image() {
|
|
local width=$1
|
|
local suffix=$2
|
|
local directory=$3
|
|
magick "$input_path" \
|
|
-auto-orient \
|
|
-strip \
|
|
-resize "${width}x>" \
|
|
-quality 82 \
|
|
"$output_root/$directory/${image_name}_${suffix}.webp"
|
|
}
|
|
|
|
# desktop (_xl) is the 5K-iMac-class tier, same ~2560px logical width the
|
|
# launcher's own top breakpoint targets (see the "iMac-class ultra-wide
|
|
# screens" comment in launcher/style.css) -- laptop (_l) covers the more
|
|
# common ~1920px screens, what this script used to just call "desktop".
|
|
resize_image 640 s phone
|
|
resize_image 1280 m tablet
|
|
resize_image 1920 l laptop
|
|
resize_image 2560 xl desktop
|
|
|
|
printf 'Created:\n'
|
|
printf ' %s\n' \
|
|
"$output_root/phone/${image_name}_s.webp" \
|
|
"$output_root/tablet/${image_name}_m.webp" \
|
|
"$output_root/laptop/${image_name}_l.webp" \
|
|
"$output_root/desktop/${image_name}_xl.webp"
|