Skip to content

Commit 05bb72f

Browse files
Merge pull request #606 from voxel51/pillow-fix
Release v0.12.2
2 parents 1d703d9 + 399af95 commit 05bb72f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

eta/core/annotations.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,7 @@ def _draw_bounding_box(
16631663

16641664
# Title background
16651665
if title_str:
1666-
textw, texth = font.getsize(title_str)
1666+
textw, texth = _get_text_size(font, title_str)
16671667
bgtlx = boxtlx - linewidth + 1
16681668
bgbry = boxtly - linewidth + 1
16691669
bgbrx = bgtlx + textw + 2 * (label_text_pad_pixels + _DX)
@@ -1912,8 +1912,17 @@ def _parse_hex_color(h):
19121912
return rgb
19131913

19141914

1915+
def _get_text_size(font, text_str):
1916+
try:
1917+
_, _, w, h = font.getbbox(text_str)
1918+
except AttributeError:
1919+
w, h = font.getsize(text_str) # Pillow<8
1920+
1921+
return w, h
1922+
1923+
19151924
def _compute_max_text_size(font, text_strs):
1916-
sizes = [font.getsize(s) for s in text_strs]
1925+
sizes = [_get_text_size(font, s) for s in text_strs]
19171926
width, height = np.max(sizes, axis=0)
19181927
return width, height
19191928

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from wheel.bdist_wheel import bdist_wheel
1717

1818

19-
VERSION = "0.12.1"
19+
VERSION = "0.12.2"
2020

2121

2222
class BdistWheelCustom(bdist_wheel):

0 commit comments

Comments
 (0)