I want to use caption -gravity center to center a long text in an image with word wrap. What I *ALWAYS* get is efectively northwest, left justified.
Using label with -gravity center, I get centered text, but it wraps off both sides.
Here is the code, including setting up the example.
Code: Select all
#!/bin/bash
#Code:
file=temp/somefile
line1=`echo "By default the text is all left justified, however as of IM version 6.2.0, 'caption:' respects '-gravity' for text justification purposes."`
line2=`echo "NOT!"`
line3=`echo "Output is North L-J"`
echo $line1 > "${file}"
echo $line2 >> "${file}"
echo $line3 >> "${file}"
title=$file
# foregoing recreates script structure creating the text to be imaged
# create blank white background just for this example
convert -background white -font Liberation-Serif-Regular -pointsize 1 -fill black -size 800x340 -gravity south label:"." label0.png
# first version: using label
convert -background black -transparent black -font Liberation-Serif-Regular -pointsize 34 -fill "dark blue" -size 800x340 -gravity center label:@"${title}" label1.png
composite -geometry -10+50 label1.png label0.png -blend 99 label2.png
# works FINE, except that it overwraps the long line!
# second version: using caption
convert -background black -transparent black -font Liberation-Serif-Regular -pointsize 34 -fill "dark blue" -size 800x340 -gravity center caption:@"${title}" label3.png
composite -geometry -10+50 label3.png label0.png -blend 99 label4.png
Any and all help appreciated.