-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Hack202406 #8154
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
Closed
Closed
Hack202406 #8154
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1c2d465
Add tests for opening 2-5 layer uint16 greyscale TIFFs.
mairsbw e0bb623
Add open() support for 2-5 band uint16 TIFFs.
mairsbw 9cbb840
Merge PR1839 into hack202406
yoursunny 90840ae
XXX disable PyImaging_MapBuffer
yoursunny 03df357
TIFF sample format table
yoursunny 936439b
introduce multi-band format (TIFF only)
yoursunny a4fab13
re-enable PyImaging_MapBuffer
yoursunny 76d336d
TIFF more entries in OPEN_INFO
yoursunny ed15ed9
cgetpixel_mb constant size buffer
yoursunny fb7702f
mb_shuffle big endian
yoursunny 86e7fc6
copy() with multi-band format
yoursunny 587bb98
crop() with multi-band format
yoursunny 0df0935
ImagingNew2Dirty update mismatch condition
yoursunny c4434df
FLIP_LEFT_RIGHT with multi-band format
yoursunny c5ebc81
explain how mode=MB is stored
yoursunny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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
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
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -60,6 +60,7 @@ | |||
| from .TiffTags import TYPES | ||||
|
|
||||
| logger = logging.getLogger(__name__) | ||||
| logger.setLevel(logging.DEBUG) # XXX hack202406 | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|
|
||||
| # Set these to true to force use of libtiff for reading or writing. | ||||
| READ_LIBTIFF = False | ||||
|
|
@@ -182,6 +183,43 @@ | |||
| (II, 1, (1,), 1, (12,), ()): ("I;16", "I;12"), | ||||
| (II, 0, (1,), 1, (16,), ()): ("I;16", "I;16"), | ||||
| (II, 1, (1,), 1, (16,), ()): ("I;16", "I;16"), | ||||
| (II, 1, (1, 1), 1, (16, 16), (0,)): ("MB", "MB"), | ||||
| ( | ||||
| II, | ||||
| 1, | ||||
| (1, 1, 1), | ||||
| 1, | ||||
| (16, 16, 16), | ||||
| ( | ||||
| 0, | ||||
| 0, | ||||
| ), | ||||
| ): ("MB", "MB"), | ||||
| ( | ||||
| II, | ||||
| 1, | ||||
| (1, 1, 1, 1), | ||||
| 1, | ||||
| (16, 16, 16, 16), | ||||
| ( | ||||
| 0, | ||||
| 0, | ||||
| 0, | ||||
| ), | ||||
| ): ("MB", "MB"), | ||||
| ( | ||||
| II, | ||||
| 1, | ||||
| (1, 1, 1, 1, 1), | ||||
| 1, | ||||
| (16, 16, 16, 16, 16), | ||||
| ( | ||||
| 0, | ||||
| 0, | ||||
| 0, | ||||
| 0, | ||||
| ), | ||||
| ): ("MB", "MB"), | ||||
| (MM, 1, (1,), 1, (16,), ()): ("I;16B", "I;16B"), | ||||
| (II, 1, (1,), 2, (16,), ()): ("I;16", "I;16R"), | ||||
| (II, 1, (2,), 1, (16,), ()): ("I", "I;16S"), | ||||
|
|
@@ -196,7 +234,9 @@ | |||
| (II, 1, (1,), 1, (8, 8), (2,)): ("LA", "LA"), | ||||
| (MM, 1, (1,), 1, (8, 8), (2,)): ("LA", "LA"), | ||||
| (II, 2, (1,), 1, (8, 8, 8), ()): ("RGB", "RGB"), | ||||
| (II, 2, (1, 1, 1), 1, (8, 8, 8), ()): ("RGB", "RGB"), | ||||
| (MM, 2, (1,), 1, (8, 8, 8), ()): ("RGB", "RGB"), | ||||
| (MM, 2, (1, 1, 1), 1, (8, 8, 8), ()): ("RGB", "RGB"), | ||||
| (II, 2, (1,), 2, (8, 8, 8), ()): ("RGB", "RGB;R"), | ||||
| (MM, 2, (1,), 2, (8, 8, 8), ()): ("RGB", "RGB;R"), | ||||
| (II, 2, (1,), 1, (8, 8, 8, 8), ()): ("RGBA", "RGBA"), # missing ExtraSamples | ||||
|
|
@@ -209,11 +249,13 @@ | |||
| (MM, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0, 0)): ("RGBX", "RGBXXX"), | ||||
| (II, 2, (1,), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBa"), | ||||
| (MM, 2, (1,), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBa"), | ||||
| (MM, 2, (1, 1, 1, 1), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBa"), | ||||
| (II, 2, (1,), 1, (8, 8, 8, 8, 8), (1, 0)): ("RGBA", "RGBaX"), | ||||
| (MM, 2, (1,), 1, (8, 8, 8, 8, 8), (1, 0)): ("RGBA", "RGBaX"), | ||||
| (II, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (1, 0, 0)): ("RGBA", "RGBaXX"), | ||||
| (MM, 2, (1,), 1, (8, 8, 8, 8, 8, 8), (1, 0, 0)): ("RGBA", "RGBaXX"), | ||||
| (II, 2, (1,), 1, (8, 8, 8, 8), (2,)): ("RGBA", "RGBA"), | ||||
| (II, 2, (1, 1, 1, 1), 1, (8, 8, 8, 8), (2,)): ("RGBA", "RGBA"), | ||||
| (MM, 2, (1,), 1, (8, 8, 8, 8), (2,)): ("RGBA", "RGBA"), | ||||
| (II, 2, (1,), 1, (8, 8, 8, 8, 8), (2, 0)): ("RGBA", "RGBAX"), | ||||
| (MM, 2, (1,), 1, (8, 8, 8, 8, 8), (2, 0)): ("RGBA", "RGBAX"), | ||||
|
|
@@ -222,13 +264,16 @@ | |||
| (II, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"), # Corel Draw 10 | ||||
| (MM, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"), # Corel Draw 10 | ||||
| (II, 2, (1,), 1, (16, 16, 16), ()): ("RGB", "RGB;16L"), | ||||
| (II, 2, (1, 1, 1), 1, (16, 16, 16), ()): ("RGB", "RGB;16L"), | ||||
| (MM, 2, (1,), 1, (16, 16, 16), ()): ("RGB", "RGB;16B"), | ||||
| (II, 2, (1,), 1, (16, 16, 16, 16), ()): ("RGBA", "RGBA;16L"), | ||||
| (MM, 2, (1,), 1, (16, 16, 16, 16), ()): ("RGBA", "RGBA;16B"), | ||||
| (II, 2, (1,), 1, (16, 16, 16, 16), (0,)): ("RGBX", "RGBX;16L"), | ||||
| (MM, 2, (1,), 1, (16, 16, 16, 16), (0,)): ("RGBX", "RGBX;16B"), | ||||
| (II, 2, (1,), 1, (16, 16, 16, 16), (1,)): ("RGBA", "RGBa;16L"), | ||||
| (II, 2, (1, 1, 1, 1), 1, (16, 16, 16, 16), (1,)): ("RGBA", "RGBa;16L"), | ||||
| (MM, 2, (1,), 1, (16, 16, 16, 16), (1,)): ("RGBA", "RGBa;16B"), | ||||
| (MM, 2, (1, 1, 1, 1), 1, (16, 16, 16, 16), (1,)): ("RGBA", "RGBa;16B"), | ||||
| (II, 2, (1,), 1, (16, 16, 16, 16), (2,)): ("RGBA", "RGBA;16L"), | ||||
| (MM, 2, (1,), 1, (16, 16, 16, 16), (2,)): ("RGBA", "RGBA;16B"), | ||||
| (II, 3, (1,), 1, (1,), ()): ("P", "P;1"), | ||||
|
|
@@ -262,9 +307,11 @@ | |||
| # JPEG compressed images handled by LibTiff and auto-converted to RGBX | ||||
| # Minimal Baseline TIFF requires YCbCr images to have 3 SamplesPerPixel | ||||
| (II, 6, (1,), 1, (8, 8, 8), ()): ("RGB", "RGBX"), | ||||
| (II, 6, (1, 1, 1), 1, (8, 8, 8), ()): ("RGB", "RGBX"), | ||||
| (MM, 6, (1,), 1, (8, 8, 8), ()): ("RGB", "RGBX"), | ||||
| (II, 8, (1,), 1, (8, 8, 8), ()): ("LAB", "LAB"), | ||||
| (MM, 8, (1,), 1, (8, 8, 8), ()): ("LAB", "LAB"), | ||||
| # XXX hack202406 these entries allow all TIFF tests to pass, but more may be needed | ||||
| } | ||||
|
|
||||
| MAX_SAMPLESPERPIXEL = max(len(key_tp[4]) for key_tp in OPEN_INFO) | ||||
|
|
@@ -1379,14 +1426,6 @@ def _setup(self): | |||
| logger.debug("- size: %s", self.size) | ||||
|
|
||||
| sample_format = self.tag_v2.get(SAMPLEFORMAT, (1,)) | ||||
| if len(sample_format) > 1 and max(sample_format) == min(sample_format) == 1: | ||||
| # SAMPLEFORMAT is properly per band, so an RGB image will | ||||
| # be (1,1,1). But, we don't support per band pixel types, | ||||
| # and anything more than one band is a uint8. So, just | ||||
| # take the first element. Revisit this if adding support | ||||
| # for more exotic images. | ||||
| sample_format = (1,) | ||||
|
|
||||
| bps_tuple = self.tag_v2.get(BITSPERSAMPLE, (1,)) | ||||
| extra_tuple = self.tag_v2.get(EXTRASAMPLES, ()) | ||||
| if photo in (2, 6, 8): # RGB, YCbCr, LAB | ||||
|
|
@@ -1442,6 +1481,9 @@ def _setup(self): | |||
|
|
||||
| logger.debug("- raw mode: %s", rawmode) | ||||
| logger.debug("- pil mode: %s", self.mode) | ||||
| if self.mode == "MB": | ||||
| assert max(bps_tuple) == min(bps_tuple) | ||||
| self.newconfig = (max(bps_tuple), samples_per_pixel) | ||||
|
|
||||
| self.info["compression"] = self._compression | ||||
|
|
||||
|
|
||||
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
Oops, something went wrong.
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.
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.
Could we have a more descriptive name for this?