Once exif data is parsed, do not reload unless it changes#6335
Merged
hugovk merged 1 commit intopython-pillow:mainfrom Jun 1, 2022
Merged
Once exif data is parsed, do not reload unless it changes#6335hugovk merged 1 commit intopython-pillow:mainfrom
hugovk merged 1 commit intopython-pillow:mainfrom
Conversation
|
@radarhere Just tested this PR and it also fixes the issue. |
Contributor
|
@radarhere in my plugin if self._exif is None:
self._exif = Exif()
self._exif._loaded = False
elif self._exif._loaded: # <--- this is always true when use ImageSequence.Iterator in Pillow 9.2
return self._exif
self._exif._loaded = Trueshould I reset in plugin |
Member
Author
|
Hi. You could set Without knowing exactly what your code does, I might alternatively suggest calling |
bigcat88
added a commit
to bigcat88/pillow_heif
that referenced
this pull request
Jul 2, 2022
This was referenced Jul 27, 2022
gasman
added a commit
to demozoo/demozoo
that referenced
this pull request
Nov 27, 2022
This fixes the issue with retrieving EXIF data from a TIFF file (probably in python-pillow/Pillow#6335), so the check for JPEG format is no longer needed.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #6334
The issue features a user calling
im.getexif(), modifying the exif data, and then saving to a TIFF file.However, when saving TIFF makes sure that the exif data has been read with
getexif(), which then loads the data withExif.load_from_fp. This reloads the exif data, overriding the user's changes.The solution is to prevent the exif data from being loaded again if it has already been parsed.
While
Exif.load()checks that it is not reloading the same input, this is not done forExif.load_from_fp(). To add that check specifically forload_from_fpwould require storing the file pointer to ensure that it is the same file being read, and storing the file pointer would mean that it needs to be considered as part of the file handling lifecycle.Instead, this PR adds a
_loadedattribute. Once set,getexif()does not load the exif data anymore, but just returns the existing object. The attribute is cleared when the exif data is changed by seek operations so that the updated exif data can be loaded.