#!/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=("576" "768" "992" "1200" "1400")

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

