#!/bin/bash #!/bin/bash # Check if two arguments are provided #if [ $# -lt 3 ]; then # echo "Usage: $0 " # exit 1 #fi # Assign arguments to variables #input_file="$1" #output_prefix="$2" #title="$3" 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}" ############################### # Input file and output file wtitle_prefix="${output_prefix}-title" output_file="${wtitle_prefix}.png" # Text lines and their font sizes line1="${title}" line1_font_size=180 line2="www.GrailHeart.com" line2_font_size=120 # Font and text color font="./Caudex-Regular.ttf" # Path to the Caudex font text_color="#111111" # Specify the color in hex # Temporary text images text_image1="_text1.png" text_image2="_text2.png" # Create temporary text images for each line magick -size 3000x200 -background none -gravity north \ -font "$font" -pointsize "$line1_font_size" -fill "$text_color" \ label:"$line1" "$text_image1" magick -size 3000x200 -background none -gravity north \ -font "$font" -pointsize "$line2_font_size" -fill "$text_color" \ label:"$line2" "$text_image2" # Get 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)) # 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" # Clean up temporary text images rm "$text_image1" "$text_image2" echo "PNG file created: $output_file"