Skip to content

Commit

Permalink
Fix an issue in applying icc color profiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Feb 2, 2023
1 parent 42eefe7 commit 4350097
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## 1.20.0

### Features
- ICC color profile support ([#1037](../../pull/1037), [#1043](../../pull/1043))
- ICC color profile support ([#1037](../../pull/1037), [#1043](../../pull/1043), [#1046](../../pull/1046))

### Improvements
- Speed up generating tiles for some multi source files ([#1035](../../pull/1035))
Expand Down
11 changes: 6 additions & 5 deletions large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1463,15 +1463,16 @@ def _outputTile(self, tile, tileEncoding, x, y, z, pilImageAllowed=False,
maxX = (x + 1) * self.tileWidth
maxY = (y + 1) * self.tileHeight
isEdge = maxX > sizeX or maxY > sizeY
hasStyle = (
(getattr(self, 'style', None) or hasattr(self, '_iccprofiles')) and
getattr(self, 'style', None) != {'icc': False})
if (tileEncoding not in (TILE_FORMAT_PIL, TILE_FORMAT_NUMPY) and
numpyAllowed != 'always' and tileEncoding == self.encoding and
not isEdge and (not applyStyle or not getattr(self, 'style', None))):
not isEdge and (not applyStyle or not hasStyle)):
return tile
mode = None
if (numpyAllowed == 'always' or tileEncoding == TILE_FORMAT_NUMPY or (applyStyle and (
(getattr(self, 'style', None) or hasattr(self, '_iccprofiles')) and
getattr(self, 'style', None) != {'icc': False})) or
isEdge):
if (numpyAllowed == 'always' or tileEncoding == TILE_FORMAT_NUMPY or
(applyStyle and hasStyle) or isEdge):
tile, mode = self._outputTileNumpyStyle(
tile, applyStyle, x, y, z, self._getFrame(**kwargs))
if isEdge:
Expand Down
4 changes: 3 additions & 1 deletion test/test_source_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,9 @@ def testFromTiffRGBJPEG():
'TCGA-AA-A02O-11A-01-BS1.8b76f05c-4a8b-44ba-b581-6b8b4f437367.svs')
source = large_image_source_tiff.open(imagePath)
tile = source.getSingleTile()
assert list(tile['tile'][0, 0]) == [243, 243, 243]
# Handle ICC Profiles
assert list(tile['tile'][0, 0]) == [243, 243, 243] or list(
tile['tile'][0, 0]) == [242, 243, 242]


def testTilesFromMultiFrameTiff():
Expand Down

0 comments on commit 4350097

Please sign in to comment.