input_file="TheThreeCalamaties-3200x1828.jpg" output_prefix="TheThreeCalamaties" title="The Three Calamaties" # Check if the input file exists if [ ! -f "$input_file" ]; then echo "Error: File '$input_file' does not exist." exit 1 fi # Get dimensions of the input image width=$(magick identify -format "%w" "$input_file") height=$(magick identify -format "%h" "$input_file") echo "Input file is ${width}x${height}" ############################### # Text lines and their font sizes line1="${title}" line1_font_size=180 line1_padding=50 # Padding for line 1 (top padding in pixels) line2="www.GrailHeart.com" line2_font_size=120 line2_padding=30 # Padding for line 2 (top padding in pixels) # Font font="./Caudex-Regular.ttf" # Path to the Caudex font # Colors to loop through colors=("111111" "222222" "333333") # Loop through colors for color in "${colors[@]}"; do # Temporary text images text_image1="_text1_${color}.png" text_image2="_text2_${color}.png" # Create temporary text images for each line with the current color, trim excess padding, and add top padding magick -background none -gravity center \ -font "$font" -pointsize "$line1_font_size" -fill "#${color}" \ label:"$line1" -trim +repage \ -splice 0x${line1_padding} "$text_image1" magick -background none -gravity center \ -font "$font" -pointsize "$line2_font_size" -fill "#${color}" \ label:"$line2" -trim +repage \ -splice 0x${line2_padding} "$text_image2" # Get the adjusted dimensions of the text images text_height1=$(magick identify -format "%h" "$text_image1") text_height2=$(magick identify -format "%h" "$text_image2") # Calculate total canvas height canvas_height=$((height + text_height1 + text_height2 + 30)) # Output file name output_file="${output_prefix}-${color}.png" # Create a transparent canvas and compose the final image magick -size ${width}x${canvas_height} xc:none \ \( "$input_file" -gravity north \) -composite \ \( "$text_image1" -gravity south -geometry +0+$((text_height2 + 20)) \) -composite \ \( "$text_image2" -gravity south -geometry +0+10 \) -composite \ "$output_file" echo "Generated: $output_file" # Clean up temporary text images rm "$text_image1" "$text_image2" done