Skip to content

Fix Exif get_ifd() when an IFD is set as a dictionary - #10721

Open
mh-masum6875 wants to merge 1 commit into
python-pillow:mainfrom
mh-masum6875:fix/exif-get-ifd-dict
Open

mh-masum6875 wants to merge 1 commit into
python-pillow:mainfrom
mh-masum6875:fix/exif-get-ifd-dict

Conversation

@mh-masum6875

Copy link
Copy Markdown

Changes proposed in this pull request:

  • Exif.tobytes() allows the Exif and GPS IFDs to be set as dictionaries, but get_ifd() treats the value as an offset. For a new Exif instance that raises an AttributeError, and it also stops the image from being saved as TIFF. For an instance that was loaded from data, an empty dictionary is returned.
  • get_ifd() now returns the dictionary. The same applies to an Interop IFD set as a dictionary inside the Exif IFD.
from PIL import Image

exif = Image.Exif()
exif[0x8825] = {18: "WGS-84"}
exif.tobytes()  # works

exif.get_ifd(0x8825)
# AttributeError: 'Exif' object has no attribute 'fp'
Image.new("L", (1, 1)).save("out.tiff", exif=exif)
# AttributeError: 'Exif' object has no attribute 'fp'

I only ran this against the 13.0.0 wheel with the change applied on top, as I don't have a C toolchain set up here.

This branch has not been deployed

No deployments
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.

1 participant