Skip to content

FFMPEG burnins break with Pillow > 9.5.0 #5

@tokejepsen

Description

@tokejepsen

Breaks with error:

# #     box_size = ifont.getsize(text)
# # AttributeError: 'FreeTypeFont' object has no attribute 'getsize'

The getsize method was deprecated and removed in newer versions of Pillow. It was replaced by textbbox() or getbbox().

Solution could be:

try:
    box_size = ifont.getsize(text)
except AttributeError:
    # Fallback for newer Pillow versions
    # Get the bounding box relative to the anchor point (0,0)
    left, top, right, bottom = ifont.getbbox(text)
    box_size = (right - left, bottom - top)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions