mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
Added im.info['icc_profile'] to results for ImageCms.applyTransform
This commit is contained in:
parent
13eb3d667a
commit
5966278643
|
@ -199,6 +199,8 @@ class ImageCmsTransform(Image.ImagePointHandler):
|
|||
self.input_mode = self.inputMode = input_mode
|
||||
self.output_mode = self.outputMode = output_mode
|
||||
|
||||
self.output_profile = output
|
||||
|
||||
def point(self, im):
|
||||
return self.apply(im)
|
||||
|
||||
|
@ -207,6 +209,7 @@ class ImageCmsTransform(Image.ImagePointHandler):
|
|||
if imOut is None:
|
||||
imOut = Image.new(self.output_mode, im.size, None)
|
||||
self.transform.apply(im.im.id, imOut.im.id)
|
||||
imOut.info['icc_profile'] = self.output_profile.tobytes()
|
||||
return imOut
|
||||
|
||||
def apply_in_place(self, im):
|
||||
|
@ -214,6 +217,7 @@ class ImageCmsTransform(Image.ImagePointHandler):
|
|||
if im.mode != self.output_mode:
|
||||
raise ValueError("mode mismatch") # wrong output mode
|
||||
self.transform.apply(im.im.id, im.im.id)
|
||||
im.info['icc_profile'] = self.output_profile.tobytes()
|
||||
return im
|
||||
|
||||
|
||||
|
|
|
@ -2,8 +2,11 @@ from helper import unittest, PillowTestCase, lena
|
|||
|
||||
from PIL import Image
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
try:
|
||||
from PIL import ImageCms
|
||||
from PIL.ImageCms import ImageCmsProfile
|
||||
ImageCms.core.profile_open
|
||||
except ImportError as v:
|
||||
# Skipped via setUp()
|
||||
|
@ -118,7 +121,7 @@ class TestImageCms(PillowTestCase):
|
|||
|
||||
def test_extensions(self):
|
||||
# extensions
|
||||
from io import BytesIO
|
||||
|
||||
i = Image.open("Tests/images/rgb.jpg")
|
||||
p = ImageCms.getOpenProfile(BytesIO(i.info["icc_profile"]))
|
||||
self.assertEqual(
|
||||
|
@ -196,6 +199,11 @@ class TestImageCms(PillowTestCase):
|
|||
# img_srgb.save('temp.srgb.tif') # visually verified vs ps.
|
||||
|
||||
self.assert_image_similar(lena(), img_srgb, 30)
|
||||
self.assertTrue(img_srgb.info['icc_profile'])
|
||||
|
||||
profile = ImageCmsProfile(BytesIO(img_srgb.info['icc_profile']))
|
||||
self.assertTrue('sRGB' in ImageCms.getProfileDescription(profile))
|
||||
|
||||
|
||||
def test_lab_roundtrip(self):
|
||||
# check to see if we're at least internally consistent.
|
||||
|
@ -205,6 +213,10 @@ class TestImageCms(PillowTestCase):
|
|||
t2 = ImageCms.buildTransform(pLab, SRGB, "LAB", "RGB")
|
||||
|
||||
i = ImageCms.applyTransform(lena(), t)
|
||||
|
||||
self.assertEqual(i.info['icc_profile'],
|
||||
ImageCmsProfile(pLab).tobytes())
|
||||
|
||||
out = ImageCms.applyTransform(i, t2)
|
||||
|
||||
self.assert_image_similar(lena(), out, 2)
|
||||
|
|
Loading…
Reference in New Issue
Block a user