Skip to content

Commit

Permalink
Add a guard if PIL doesn't support ImageCms.
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Apr 24, 2023
1 parent b1ab7a8 commit 7bb2d03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 1.20.6

### Changes
- Add a guard if PIL doesn't support ImageCms ([#1032](../../pull/1032))

### Bug Fixes
- Allow clearing the min/max fields of the frame selector ([#1030](../../pull/1030))
- Fix a bug with caching tiles and styling ([#1031](../../pull/1031))
Expand Down
11 changes: 10 additions & 1 deletion large_image/tilesource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,16 @@ def _applyICCProfile(self, sc, frame):
intent = getattr(PIL.ImageCms, 'INTENT_' + str(sc.style.get('icc')).upper(),
PIL.ImageCms.INTENT_PERCEPTUAL)
if not hasattr(self, '_iccsrgbprofile'):
self._iccsrgbprofile = PIL.ImageCms.createProfile('sRGB')
try:
self._iccsrgbprofile = PIL.ImageCms.createProfile('sRGB')
except ImportError:
self._iccsrgbprofile = None
self.logger.warning(
'Failed to import PIL.ImageCms. Cannot perform ICC '
'color adjustments. Does your platform support '
'PIL.ImageCms?')
if self._iccsrgbprofile is None:
return sc.image
try:
key = (mode, intent)
if self._iccprofilesObjects[profileIdx] is None:
Expand Down

0 comments on commit 7bb2d03

Please sign in to comment.