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 ?
Problem with Annotate method + text rotation
Re: Problem with Annotate method + text rotation
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.
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.