Skip to content

Commit

Permalink
Merge pull request #606 from voxel51/pillow-fix
Browse files Browse the repository at this point in the history
Release v0.12.2
  • Loading branch information
benjaminpkane authored Jan 2, 2024
2 parents 1d703d9 + 399af95 commit 05bb72f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions eta/core/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ def _draw_bounding_box(

# Title background
if title_str:
textw, texth = font.getsize(title_str)
textw, texth = _get_text_size(font, title_str)
bgtlx = boxtlx - linewidth + 1
bgbry = boxtly - linewidth + 1
bgbrx = bgtlx + textw + 2 * (label_text_pad_pixels + _DX)
Expand Down Expand Up @@ -1912,8 +1912,17 @@ def _parse_hex_color(h):
return rgb


def _get_text_size(font, text_str):
try:
_, _, w, h = font.getbbox(text_str)
except AttributeError:
w, h = font.getsize(text_str) # Pillow<8

return w, h


def _compute_max_text_size(font, text_strs):
sizes = [font.getsize(s) for s in text_strs]
sizes = [_get_text_size(font, s) for s in text_strs]
width, height = np.max(sizes, axis=0)
return width, height

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from wheel.bdist_wheel import bdist_wheel


VERSION = "0.12.1"
VERSION = "0.12.2"


class BdistWheelCustom(bdist_wheel):
Expand Down

0 comments on commit 05bb72f

Please sign in to comment.