Adding an image to the end of text
Adding an image to the end of text
How would I determine the width and height of the text I am creating so that I can place an image based on that width and height.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Adding an image to the end of text
I am not sure I know exactly what you mean, but I have used a two step process for creating text. First use label: to build the text, then get the dimensions, then redo with -annotate.
convert -background $bc \
-fill $tc $stroke -font $font -pointsize $point \
-gravity center label:"$text" \
-trim -bordercolor "$bc" -border 10 +repage $tmp0
wd=`identify -format %w $tmp0`
ht=`identify -format %h $tmp0`
dim="${wd}x${ht}"
convert -size $dim xc:"$bc" $fill \
$stroke -undercolor $uc \
-font $font -pointsize $point \
-gravity center -annotate 0x${italic}+0+0 "$text" \
-trim -bordercolor $bc -border $linewt +repage $tmp0
convert -background $bc \
-fill $tc $stroke -font $font -pointsize $point \
-gravity center label:"$text" \
-trim -bordercolor "$bc" -border 10 +repage $tmp0
wd=`identify -format %w $tmp0`
ht=`identify -format %h $tmp0`
dim="${wd}x${ht}"
convert -size $dim xc:"$bc" $fill \
$stroke -undercolor $uc \
-font $font -pointsize $point \
-gravity center -annotate 0x${italic}+0+0 "$text" \
-trim -bordercolor $bc -border $linewt +repage $tmp0
Re: Adding an image to the end of text
Thanks for the reply. I was trying to avoid multiple steps and was looking for a one liner. I may need to do what you have suggested.
I think I am onto a solution. Here is what I have so far. Basically I create my text then apply a -trim then I do a +composite using gravity and geometry.
The problem I am having is the resulting image is cropped. Is there a way after applying a -trim to an image to them add space around it?
I think I am onto a solution. Here is what I have so far. Basically I create my text then apply a -trim then I do a +composite using gravity and geometry.
The problem I am having is the resulting image is cropped. Is there a way after applying a -trim to an image to them add space around it?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Adding an image to the end of text
see my example. I add a generous border, then trim it later as needed after the text is added (centered) and then add whatever final border is desired. See -border in the IM docs.