diff --git a/CHANGELOG.md b/CHANGELOG.md index dc3c5e8ff..960e222f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 1.20.0 ### Features -- ICC color profile support ([#1037](../../pull/1037)) +- ICC color profile support ([#1037](../../pull/1037), [#1043](../../pull/1043)) ### Improvements - Speed up generating tiles for some multi source files ([#1035](../../pull/1035)) diff --git a/girder/girder_large_image/models/image_item.py b/girder/girder_large_image/models/image_item.py index b97405899..c7ec64b8e 100644 --- a/girder/girder_large_image/models/image_item.py +++ b/girder/girder_large_image/models/image_item.py @@ -18,7 +18,6 @@ import json import pickle -import PIL.ImageCms import pymongo from girder_jobs.constants import JobStatus from girder_jobs.models.job import Job @@ -248,9 +247,7 @@ def getInternalMetadata(self, item, **kwargs): tileSource = self._loadTileSource(item, **kwargs) result = tileSource.getInternalMetadata() or {} if tileSource.getICCProfiles(): - result['iccprofiles'] = [ - PIL.ImageCms.getProfileInfo(prof).strip() or 'present' if prof else None - for prof in tileSource.getICCProfiles()] + result['iccprofiles'] = tileSource.getICCProfiles(onlyInfo=True) result['tilesource'] = tileSource.name return result diff --git a/large_image/tilesource/base.py b/large_image/tilesource/base.py index 996e64bde..9b327b3ce 100644 --- a/large_image/tilesource/base.py +++ b/large_image/tilesource/base.py @@ -1193,13 +1193,15 @@ def _applyStyleFunction(self, image, sc, stage, function=None): self.logger.exception('Failed to execute style function %s' % function['name']) return image - def getICCProfiles(self, idx=None): + def getICCProfiles(self, idx=None, onlyInfo=False): """ Get a list of all ICC profiles that are available for the source, or get a specific profile. :param idx: a 0-based index into the profiles to get one profile, or None to get a list of all profiles. + :param onlyInfo: if idx is None and this is true, just return the + profile information. :returns: either one or a list of PIL.ImageCms.CmsProfile objects, or None if no profiles are available. If a list, entries in the list may be None. @@ -1217,6 +1219,10 @@ def getICCProfiles(self, idx=None): if idx == pidx: return prof results.append(prof) + if onlyInfo: + results = [ + PIL.ImageCms.getProfileInfo(prof).strip() or 'present' + if prof else None for prof in results] return results def _applyICCProfile(self, sc, frame):