allpawcare-website/scripts/process-images.sh
2023-12-24 14:48:52 -05:00

18 lines
495 B
Bash
Executable File

#!/usr/bin/env bash
IMG_ORIGINALS="img_original"
IMG_PUBLIC="all_paw_care/static/img"
IMG_SIZES_NAME=("sm" "md" "lg" "xl" "xxl")
IMG_SIZES=("346" "461" "595" "720" "840")
for img in $(find $IMG_ORIGINALS -type f)
do
for ((i=0;i<${#IMG_SIZES_NAME[@]};i++))
do
new_img_path=$(echo "$img" | sed -e "s,img_original\(.*\),$IMG_PUBLIC\1,g" \
-e "s,\.,_${IMG_SIZES_NAME[i]}\.,g")
magick "$img" -filter spline -resize ${IMG_SIZES[i]} "$new_img_path"
done
done