-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TIFF: report correct image size after opening #8387
Conversation
for more information, see https://pre-commit.ci
@@ -1275,6 +1275,13 @@ def load(self) -> Image.core.PixelAccess | None: | |||
return self._load_libtiff() | |||
return super().load() | |||
|
|||
@property | |||
def size(self) -> tuple[int, int]: | |||
if hasattr(self, "tag_v2"): |
There was a problem hiding this comment.
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
@@ -1275,6 +1275,13 @@ def load(self) -> Image.core.PixelAccess | None: | |||
return self._load_libtiff() | |||
return super().load() | |||
|
|||
@property | |||
def size(self) -> tuple[int, int]: |
There was a problem hiding this comment.
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
This PR was created in an effort to ensure that It naturally sounds like a good idea for images to have the same size after opening as after loading. However, Pillow also aims to open an image without loading it, for the sake of performance, and the rotation data might not appear early on in the file. For the PNG format, https://ftp-osl.osuosl.org/pub/libpng/documents/pngext-1.5.0.html#C.eXIf states
So I don't think it is possible to simultaneously achieve those two goals. |
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 |
Ah, I see now, thanks. I think introducing the idea that |
Closed in favour of #8390. |
No description provided.