You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Example code in ImageText documentation makes incorrect use of get_bbox() #10583
It will create an image of the wrong size because it will not subtract the left and top values of the bounding box. Furthermore, it will make it impossible to adjust the position of im relative to a different anchor without, again, subtracting the left and top values of the default bbox.
You can see that the image size contains all of the text when it is drawn at (0, 0) (GitHub is applying some border-radius styling, but hopefully you get the point).
You were expecting the text not to have space to the top and left of the text. That's possible with Pillow, but I don't know that it needs to be part of this specific example? I don't think everyone necessarily wants to draw text without that spacing.
The three lines that you have highlighted are intended to show that ImageText's getbbox() can get the bounding box without an ImageDraw instance. It achieves that.
Activity
radarhere commentedon Nov 22, 2026
If I take that whole example from the docs, and save the image at the end,
I get

You can see that the image size contains all of the text when it is drawn at
(0, 0)(GitHub is applying some border-radius styling, but hopefully you get the point).You were expecting the text not to have space to the top and left of the text. That's possible with Pillow, but I don't know that it needs to be part of this specific example? I don't think everyone necessarily wants to draw text without that spacing.
The three lines that you have highlighted are intended to show that
ImageText'sgetbbox()can get the bounding box without anImageDrawinstance. It achieves that.samhocevar commentedon Nov 23, 2026
Well thank you for the example, it will make it easier to explain and to understand.
If you just zoom on the picture in your example, you will see that:
You have to create an image of the proper dimensions, using the actual bounding box size:
And then you have to write the text at the proper coordinates:
This fixes both problems:
samhocevar commentedon Nov 23, 2026
FYI, it gets more obvious with a huge stroke size, such as 6:
Fixed: