hw to offset text from the top of an image and give it a text alignment of center
Re: hw to offset text from the top of an image and give it a text alignment of center
hello fred, did u test the code. am having undesired result,check pls
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: hw to offset text from the top of an image and give it a text alignment of center
When in doubt, separate the commands and look at each intermediate result to see what is happening.
In the above, I found the size of the text image before adding the red border. So I cropped it a bit smaller in width in the following.
The above is likely not what you want as I mentioned above in my previous email. And as I said before, there is no easy way that I know to do what you want. Imagemagick cannot do both wrap and trim text that is too long.
So what I think you have to do is write the text with -annotate or -draw and place each line where you want on an image of the size you want for your box before adding the border. Then add the border. Then composite image in your 500x500 white background in the place you want. This is what I said in my last email message.
Please provide an example of the way you want your result to look.
Code: Select all
convert -background white -fill black -gravity center -pointsize 36 label:"my first text" -trim +repage tmp1a.png
convert -background white -fill black -gravity center -pointsize 36 label:"center text" -trim +repage tmp2a.png
convert tmp1a.png tmp2a.png -gravity center -smush +20 -bordercolor white -border 10 tmp3a.png
convert tmp3a.png -bordercolor red -border 10 tmp3b.png
convert -size 500x500 xc:white tmp3b.png -geometry +57+146 -compose over -composite text_resultA.png
convert tmp3a.png -format "%wx%h" info:
202x99
In the above, I found the size of the text image before adding the red border. So I cropped it a bit smaller in width in the following.
Code: Select all
convert -background white -fill black -gravity center -pointsize 36 label:"my first text" -trim +repage tmp1a.png
convert -background white -fill black -gravity center -pointsize 36 label:"center text" -trim +repage tmp2a.png
convert tmp1a.png tmp2a.png -gravity center -smush +20 -bordercolor white -border 10 tmp3a.png
convert tmp3a.png -gravity northwest -crop 184x99+0+0 +repage -bordercolor red -border 10 tmp3b.png
convert -size 500x500 xc:white tmp3b.png -geometry +57+146 -compose over -composite text_resultB.png
The above is likely not what you want as I mentioned above in my previous email. And as I said before, there is no easy way that I know to do what you want. Imagemagick cannot do both wrap and trim text that is too long.
So what I think you have to do is write the text with -annotate or -draw and place each line where you want on an image of the size you want for your box before adding the border. Then add the border. Then composite image in your 500x500 white background in the place you want. This is what I said in my last email message.
Please provide an example of the way you want your result to look.
Re: hw to offset text from the top of an image and give it a text alignment of center
thanks Fred, is now working perfectly well as i expected. Am still learning anyway
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: hw to offset text from the top of an image and give it a text alignment of center
PHP exec() is no different from command line imagemagick. You just put your command in the exec("....") area.
If you want other API, there is Imagick and Magickwand for PHP. See those forums on this web site.
See also http://www.rubblewebs.co.uk/index.php
If you want other API, there is Imagick and Magickwand for PHP. See those forums on this web site.
See also http://www.rubblewebs.co.uk/index.php
Re: hw to offset text from the top of an image and give it a text alignment of center
hello moderator, please is these forum topic still open, i will want to ask some questions base on my previous questions. permitted ?? or i should create a new topic.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: hw to offset text from the top of an image and give it a text alignment of center
Best to create a new topic after so long a time.
If it is really relevant, then you can link back to this topic in your new post.
If it is really relevant, then you can link back to this topic in your new post.