Skip to content

Fixed writing bytes as ASCII tag#6493

Merged
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:bytes_ascii
Aug 31, 2022
Merged

Fixed writing bytes as ASCII tag#6493
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:bytes_ascii

Conversation

@radarhere
Copy link
Copy Markdown
Member

@radarhere radarhere commented Aug 11, 2022

Resolves #6492

The issue provides an image where tag 271 has type UNDEFINED. https://www.awaresystems.be/imaging/tiff/tifftags/make.html states tag 271 should have type ASCII. The tag is loaded as bytes then, not a string as expected, and when Pillow tries to encode the string, it fails.

This PR simply changes TiffImagePlugin to not encode if the variable is already bytes.

@hugovk hugovk merged commit 6697de1 into python-pillow:main Aug 31, 2022
@radarhere radarhere deleted the bytes_ascii branch August 31, 2022 10:47
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.

getexif().tobytes() throws 'bytes' object has no attribute 'encode'

2 participants