allpawcare-website/scripts/process-images.sh

22 lines
566 B
Bash
Executable File

#!/usr/bin/env bash
# This directory contains images for processing
IMG_ORIGINALS="$1"
# The static image directory for the website module
IMG_PUBLIC="$2"
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