I have multiple graphics, each containing a line of text (black on transparent BG)
and
In a parameterized shell script, I stitch a pair of graphics together (one on top of the other). The parameters indicate, which pair, FG color of row 1, FG color of row 2 and BG color.
I have moved on a bit since I posted my question. As the final image might only have one row of "text" and as the specified colours might be gradients requiring me to determine the height of the individual rows of "text", I do this in three steps:
In the code I am pasting in below, to make it more readable and instantly replayable, I hard-code geometry and colours where my script uses variables:
1) create B&W mask of stitched graphics
Code: Select all
convert \
pic2.png -gravity south -extent x200% pic1.png \
-negate -bordercolor black \
-reverse -append -border 5% \
mask.png
2) create foregound colour image
my code produces the result but is almost too embarrassing to post:
Code: Select all
convert \
pic2.png \
\( +clone -size 200x30 -tile gradient:yellow-green -draw "color 0,0 reset" \) \
-gravity south -extent x200% \
pic1.png \
\( +clone -size 200x43 -tile gradient:green-yellow -draw "color 0,0 reset" \) \
-delete 0,2 -reverse -append \
-bordercolor none -border 5% \
fg.png
The resultant image has the same dimensions as the mask and it contains two colour blocks where the two rows of text will be.
3) create composite from mask, foreground image + background image
Code: Select all
convert mask.png -colorspace sRGB fg.png \
\( +clone -size 220x123 -tile xc:darkblue -draw "color 0,0 reset" \) \
-reverse -compose Src -composite \
final.png
Result achieved but I am interested to learn if there's a more elegant approach. I am using IM 6.7.7.