Simple Put Alpha Text Image over Background Image
Posted: 2013-08-14T14:21:06-07:00
Hello,
I am generating an image from input text:
convert -channel RGBA -density 196 -background none -fill blue -font Times -pointsize 10 -size 400x400 -gravity North -bordercolor none -border 3 caption:'message' temp.png
This creates an image for me with the string message, of size 400x400, and transparent background. I don't care about the size of this temp image, it will contain a string of between 100 and 200 characters each time. I just want it to be text on transparent background for pasting onto another image.
This text must be placed over a background image, centered at the top but not all the way at the top, and with margins. The text itself I would like to be justified. The background image is 400x400 and must remain this size.
composite -tile background.png temp.png -compose DstOver result.png.
This is working, however the text image is just placed at the very top, per the Gravity North directive. I would like to be able to place the text more specifically on the background image, with margins/paddig.
I've tried all sorts of additional options to both the convert and composite commands (-geometry 400x400+10+10 or -geometry 400x400+40+40 or -region 400x400+40+40, using 300x300 instead of 400 for size/region/geometry, and placing the options after convert, after composite, after composite but before -compose.. using positive and negative offsets, etc.
Bottom line I don't know enough about these commands and am just looking for a one-off solution that works for my simple problem.
I would really appreciate if this is easy/simple for anyone to point out how to accomplish the placement, or better yet provide the convert and composite commands required.
Thanks!
I am generating an image from input text:
convert -channel RGBA -density 196 -background none -fill blue -font Times -pointsize 10 -size 400x400 -gravity North -bordercolor none -border 3 caption:'message' temp.png
This creates an image for me with the string message, of size 400x400, and transparent background. I don't care about the size of this temp image, it will contain a string of between 100 and 200 characters each time. I just want it to be text on transparent background for pasting onto another image.
This text must be placed over a background image, centered at the top but not all the way at the top, and with margins. The text itself I would like to be justified. The background image is 400x400 and must remain this size.
composite -tile background.png temp.png -compose DstOver result.png.
This is working, however the text image is just placed at the very top, per the Gravity North directive. I would like to be able to place the text more specifically on the background image, with margins/paddig.
I've tried all sorts of additional options to both the convert and composite commands (-geometry 400x400+10+10 or -geometry 400x400+40+40 or -region 400x400+40+40, using 300x300 instead of 400 for size/region/geometry, and placing the options after convert, after composite, after composite but before -compose.. using positive and negative offsets, etc.
Bottom line I don't know enough about these commands and am just looking for a one-off solution that works for my simple problem.
I would really appreciate if this is easy/simple for anyone to point out how to accomplish the placement, or better yet provide the convert and composite commands required.
Thanks!