Tiff ImageFileDirectory Rewrite#1419
Merged
wiredfool merged 38 commits intopython-pillow:masterfrom Sep 20, 2015
Merged
Conversation
- force cast ExtraSamples to a list. - fix calls to ImagingLibTiffSetField to include array length.
Do not represent scalar tags as 1-element tuples. Keep tag type and count information in TiffTags.TAGS. Normalize data in ImageFileDirectory.__setitem__: wrap and unwrap tuples as needed, convert rationals to floats. (To ensure consistency, make the "tags" attribute private.) Interpret byte data as a series of integers rather than a bytearray (which should only map to the "undefined" type). On Python3, if a str is assigned to an "undefined" tag, encode it as ASCII. Note that a large number of tags have been removed from TiffTags.TAGS because I do not have time to figure out the type and count of each of them. They should be restored before this gets merged in. This obviously breaks backwards compatibility in a lot of ways...
To have the old API that always returns tuples, and fractions as pairs, set the `legacy_api` attribute of the IFD to True. This should alleviate concerns about backwards compatibility.
Some programs generate SamplesPerPixel entries in ExtraSamples instead of SamplesPerPixel-3, cf. python-pillow#1227. This is a stopgap measure to support them. One could also decide to add generic code to always support having SamplesPerPixel entries (by dropping the first 3).
By interleaving little and big-endian entries we make sure entries exist for both cases. Some additional entries created when the big-endian was missing. I am not sure of what entry to create for the big-endian, 4-bit case (what is the order of the two entries within the byte?).
…New IFD is putting textdata in type7 metadata and returning bytes, old one put it in type 2 string and returned a string. This may be an issue
…e both _tags_v* when saving as legacy api
df9760e to
ca24a44
Compare
a1efc69 to
b56d5ca
Compare
Member
Author
|
We're down to two classes of test failure against current master (f451e40). This was an internal implementation detail that's been removed: This test is looking into the cached, parsed tag dict, not using the public interface to populate that dict. I'm calling this good for lingering test failures. |
Member
Author
|
Ok, I think I'm done here, pending anything else showing up. |
wiredfool
added a commit
that referenced
this pull request
Sep 20, 2015
Tiff ImageFileDirectory Rewrite
Closed
Closed
This was referenced Aug 8, 2019
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.
This is my take on #1059, which is a pretty full rewrite of the Tiff ImageFileDirectory for correctness. This is not complete, as there are still several issues that need to be addressed.
I had several issues with the PR, which I've attempted to fix here.
This PR:
test_file_tiff.py:test_page_number_x_0segfaultstest_file_tiff.py:test_xyres_tiffhad a portion where integer resolution was tested, this is stubbed out.Needs
test_file_tiff.py:test_page_number_x_0test_file_tiff.py:test_xyres_tifftest_file_tiff_metadata.pyMy intention is that this land before 3.0.0. Please test and comment.