Skip to content
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

Fix getPixel for single channel sources. #875

Merged
merged 1 commit into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## Unreleased

### Bug Fixes
- Fix getPixel for single channel sources ([875](../../pull/875))

## 1.14.5

### Improvements
Expand Down
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