Last active
March 2, 2025 11:18
-
-
Save blackknight36/fea4e202b0a898fbe6cca85721529e76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -f /usr/local/bin/magick ]; then | |
cmd="magick" | |
elif [ -f /usr/local/bin/convert ]; then | |
cmd="convert" | |
else | |
echo "ImageMagick is required to run this script. Please ensure that ImageMagick is installed and try again." | |
fi | |
if ! [ -d resized ] ; then | |
mkdir resized | |
fi | |
if ! [ -d bleed ] ; then | |
mkdir bleed | |
fi | |
# 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 "Resizing $image to fit 744x1038 (cut area)" | |
$cmd "$image" -background black -resize 744x1038 -gravity center -extent 744x1038 "resized/resized_${image%.*}.${image##*.}" | |
# 816 x 1110 pixels (300DPI) | Max file size 32MB | |
# Step 2: Add a 38-pixel bleed on each side, resulting in 816 x 1110 pixels (full bleed) | |
$cmd "resized/resized_${image%.*}.${image##*.}" -background black -gravity center -extent 816x1110 "$output_file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment