Skip to content

Conversation

@radarhere
Copy link
Member

@radarhere radarhere commented May 15, 2025

Resolves #8957

The issue has found that XMP tag bytes may contain non-ascii bytes. This raises an error when trying to parse them to get the orientation.

Pillow/src/PIL/Image.py

Lines 1541 to 1544 in 3c71559

if not xmp_tags and (xmp_tags := self.info.get("xmp")):
xmp_tags = xmp_tags.decode("utf-8")
if xmp_tags:
match = re.search(r'tiff:Orientation(="|>)([0-9])', xmp_tags)

Instead of changing the XMP tag bytes to a string to match the pattern, this PR changes the pattern to bytes to match the XMP tag bytes.

@hugovk hugovk merged commit 646885e into python-pillow:main Jun 10, 2025
55 checks passed
@radarhere radarhere deleted the xmp branch June 10, 2025 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image.getexif() errors on n04532106_1553.JPEG from ImageNet

2 participants