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 line2="www.GrailHeart.com" line2_font_size=120 # Font font="./Caudex-Regular.ttf" # Path to the Caudex font # Colors to loop through colors=("ff0000" "00ff00" "0000ff") # 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 and trim excess padding magick -background none -gravity center \ -font "$font" -pointsize "$line1_font_size" -fill "#${color}" \ label:"$line1" -trim +repage "$text_image1" magick -background none -gravity center \ -font "$font" -pointsize "$line2_font_size" -fill "#${color}" \ label:"$line2" -trim +repage "$text_image2" # Get the trimmed 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