@@ -213,22 +213,21 @@ To include the profile in an image file when saving the image to disk::
213213 image.save(filename, icc_profile=image.info.get('icc_profile'))
214214
215215To perform color conversions using the profile, import it into
216- :mod: `ImageCms <PIL.ImageCms> `. For example, to convert an image in-place
217- to a synthesized sRGB profile, using absolute colorimetric rendering::
216+ :mod: `ImageCms <PIL.ImageCms> `. For example, to synthesize an sRGB profile
217+ and use it to transform an image for display, with the default rendering
218+ intent of the image's profile::
218219
219220 from io import BytesIO
220221 from PIL import ImageCms
221222
222223 fromProfile = ImageCms.getOpenProfile(BytesIO(image.info['icc_profile']))
223224 toProfile = ImageCms.createProfile('sRGB')
225+ intent = ImageCms.getDefaultIntent(fromProfile)
224226 ImageCms.profileToProfile(
225- image, fromProfile, toProfile,
226- ImageCms.Intent.ABSOLUTE_COLORIMETRIC, 'RGBA', True, 0
227+ image, fromProfile, toProfile, intent, 'RGBA', True, 0
227228 )
228229
229- Absolute colorimetric rendering `maximizes the comparability `_ of images
230- produced by different scanners. When converting Deep Zoom tiles, use
231- ``'RGB' `` instead of ``'RGBA' ``.
230+ When converting Deep Zoom tiles, use ``'RGB' `` instead of ``'RGBA' ``.
232231
233232All pyramid regions in a slide have the same profile, but each associated
234233image can have its own profile. As a convenience, the former is also
@@ -238,15 +237,13 @@ by building an :class:`~PIL.ImageCms.ImageCmsTransform` for the slide and
238237reusing it for multiple slide regions::
239238
240239 toProfile = ImageCms.createProfile('sRGB')
240+ intent = ImageCms.getDefaultIntent(slide.color_profile)
241241 transform = ImageCms.buildTransform(
242- slide.color_profile, toProfile, 'RGBA', 'RGBA',
243- ImageCms.Intent.ABSOLUTE_COLORIMETRIC, 0
242+ slide.color_profile, toProfile, 'RGBA', 'RGBA', intent, 0
244243 )
245244 # for each region image:
246245 ImageCms.applyTransform(image, transform, True)
247246
248- .. _maximizes the comparability : https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4478790/
249-
250247
251248Caching
252249-------
0 commit comments