TIFF: report correct image size after opening by homm · Pull Request #8387 · python-pillow/Pillow
|
|
||
| @property | ||
| def size(self) -> tuple[int, int]: | ||
| if hasattr(self, "tag_v2"): |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a cases after copying or pickling, when the class is actually TiffImageFile, but it is loaded and doesn't have tag_v2 attribute
homm
mentioned this pull request
| return super().load() | ||
|
|
||
| @property | ||
| def size(self) -> tuple[int, int]: |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation is differ from uploadcare@1d77bfe since for me it looks less magical, but if you can't agree, I can copy the previous as is
There is no conflict between the presence of eXIf chunks in PNG files and the goal of "having the same size after opening as after loading," because when loading a PNG (by calling the .load() method or any dependent method), the Exif data is populated, but the image is not automatically rotated. This differs from the behavior of TIFF, where calling .load() actually rotates the image and can change its size. This is exactly the issue I aim to address in this PR.
Ah, I see now, thanks.
I think introducing the idea that im.size might not match im._size complicates things. How about #8390 instead?
Closed in favour of #8390.
hugovk
deleted the
tiff-correct-size
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters