Skip to content

Commit

Permalink
Fix getPixel for single channel sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Jun 16, 2022
1 parent c805a26 commit cb5fe45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2411,7 +2411,10 @@ def getPixel(self, includeTileRecord=False, **kwargs):
pixel['tile'] = tile
img = tile['tile']
if img.size[0] >= 1 and img.size[1] >= 1:
pixel.update(dict(zip(img.mode.lower(), img.load()[0, 0])))
if len(img.mode) > 1:
pixel.update(dict(zip(img.mode.lower(), img.load()[0, 0])))
else:
pixel.update(dict(zip([img.mode.lower()], [img.load()[0, 0]])))
return pixel


Expand Down
1 change: 1 addition & 0 deletions test/test_source_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def testSourcesTilesAndMethods(source, filename):
assert ts.getInternalMetadata() is not None
assert ts.getOneBandInformation(1) is not None
assert len(ts.getBandInformation()) >= 1
assert ts.getPixel(region=dict(left=0, top=0)) is not None
# Histograms are too slow to test in this way
# assert len(ts.histogram()['histogram']) >= 1
# assert ts.histogram(onlyMinMax=True)['min'][0] is not None
Expand Down

0 comments on commit cb5fe45

Please sign in to comment.