#!/bin/bash

# Process each PNG image
for image in *.png; do
    # Define the output file path for the processed image with bleed
    output_file="bleed/${image%.*}_with_bleed.${image##*.}"

    # Skip processing if the output file already exists
    if [ -f "$output_file" ]; then
        echo "Skipping $image - already processed"
        continue
    fi

    echo "Processing $image"

    # Step 1: Resize the image to 744 x 1038 pixels (cut area)
    magick "$image" -resize 744x1038 -gravity center -extent 744x1038 "resized/resized_${image%.*}.${image##*.}"

    # Step 2: Add a 36-pixel bleed on each side, resulting in 822 x 1122 pixels (full bleed)
    magick "resized/resized_${image%.*}.${image##*.}" -background white -gravity center -extent 822x1122 "$output_file"
done