Page 1 of 1

Problem with Annotate method + text rotation

Posted: 2011-11-28T23:55:00-07:00
by spok
I'd like to annotate an image with a text which can be rotated by 0,90, 180 or 270 degrees.
The angle is not known in advance. The font size also is not known in advance.
I use the gravity to choose the text position.
When the gravity is in the center, everything works well.
However when the gravity is in another position (corner for example) if I use the angle parameter of the annotate method to rotate the text, then the text disappears outside the image.
How can I make the text stay inside the image after the rotation ?

Re: Problem with Annotate method + text rotation

Posted: 2011-11-29T06:01:56-07:00
by spok
Finally I found another solution.
I created a new pic with the same size as the image and with a transparent backgound.
Then I annotated this new image with the text.
Then I croped this image with boundingBox method to obtain an image only with a size correponding to the text inside.
The I rotated this image.
And finally I used composite with the original image.