Skip to content

Commit c8216b5

Browse files
authored
Account for newer Pillow versions
1 parent 78effeb commit c8216b5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/otio_burnins_adapter/ffmpeg_burnins.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,16 @@ def _drawtext(align, resolution, text, options):
384384
elif align in (TOP_RIGHT, BOTTOM_RIGHT):
385385
ifont = ImageFont.truetype(options['font'],
386386
options['font_size'])
387-
box_size = ifont.getsize(text)
387+
388+
# A more robust solution might involve a try-except block
389+
try:
390+
box_size = ifont.getsize(text)
391+
except AttributeError:
392+
# Fallback for newer Pillow versions
393+
# Get the bounding box relative to the anchor point (0,0)
394+
left, top, right, bottom = ifont.getbbox(text)
395+
box_size = (right - left, bottom - top)
396+
388397
x_pos = resolution[0] - (box_size[0] + options['x_offset'])
389398
elif align in (TOP_LEFT, BOTTOM_LEFT):
390399
x_pos = options['x_offset']

0 commit comments

Comments
 (0)