Ejemplo n.º 1
0
 def test06_create_transform_with_custom_flags(self):
     self.assertNotEqual(
         None,
         libcms.cms_create_transform(
             self.inProfile, uc2const.TYPE_RGB_8, self.outProfile,
             uc2const.TYPE_CMYK_8, uc2const.INTENT_PERCEPTUAL,
             uc2const.cmsFLAGS_NOTPRECALC | uc2const.cmsFLAGS_GAMUTCHECK))
     self.assertNotEqual(
         None,
         libcms.cms_create_transform(
             self.inProfile, uc2const.TYPE_RGB_8, self.outProfile,
             uc2const.TYPE_CMYK_8, uc2const.INTENT_PERCEPTUAL,
             uc2const.cmsFLAGS_PRESERVEBLACK
             | uc2const.cmsFLAGS_BLACKPOINTCOMPENSATION))
     self.assertNotEqual(
         None,
         libcms.cms_create_transform(
             self.inProfile, uc2const.TYPE_RGB_8, self.outProfile,
             uc2const.TYPE_CMYK_8, uc2const.INTENT_PERCEPTUAL,
             uc2const.cmsFLAGS_NOTPRECALC
             | uc2const.cmsFLAGS_HIGHRESPRECALC))
     self.assertNotEqual(
         None,
         libcms.cms_create_transform(
             self.inProfile, uc2const.TYPE_RGB_8, self.outProfile,
             uc2const.TYPE_CMYK_8, uc2const.INTENT_PERCEPTUAL,
             uc2const.cmsFLAGS_NOTPRECALC
             | uc2const.cmsFLAGS_LOWRESPRECALC))
Ejemplo n.º 2
0
	def test07_create_transform_with_invalid_intent(self):
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8, 3))
		try:
			libcms.cms_create_transform(self.inProfile, uc2const.TYPE_RGB_8,
									self.outProfile, uc2const.TYPE_CMYK_8, 4)
		except libcms.CmsError:
			return
		self.fail()
Ejemplo n.º 3
0
	def test04_create_transform(self):
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8))
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGBA_8, self.outProfile, uc2const.TYPE_CMYK_8))
		self.assertNotEqual(None, libcms.cms_create_transform(self.outProfile,
				uc2const.TYPE_CMYK_8, self.inProfile, uc2const.TYPE_RGBA_8))
		self.assertNotEqual(None, libcms.cms_create_transform(self.outProfile,
				uc2const.TYPE_CMYK_8, self.inProfile, uc2const.TYPE_RGB_8))
Ejemplo n.º 4
0
	def test04_create_transform(self):
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8))
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGBA_8, self.outProfile, uc2const.TYPE_CMYK_8))
		self.assertNotEqual(None, libcms.cms_create_transform(self.outProfile,
				uc2const.TYPE_CMYK_8, self.inProfile, uc2const.TYPE_RGBA_8))
		self.assertNotEqual(None, libcms.cms_create_transform(self.outProfile,
				uc2const.TYPE_CMYK_8, self.inProfile, uc2const.TYPE_RGB_8))
Ejemplo n.º 5
0
	def test07_create_transform_with_invalid_intent(self):
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8, 3))
		try:
			libcms.cms_create_transform(self.inProfile, uc2const.TYPE_RGB_8,
									self.outProfile, uc2const.TYPE_CMYK_8, 4)
		except libcms.CmsError:
			return
		self.fail()
Ejemplo n.º 6
0
def test_create_transform_with_invalid_intent():
    assert libcms.cms_create_transform(IN_PROFILE, uc2const.TYPE_RGB_8,
                                       OUT_PROFILE, uc2const.TYPE_CMYK_8,
                                       3) is not None
    try:
        libcms.cms_create_transform(IN_PROFILE, uc2const.TYPE_RGB_8,
                                    OUT_PROFILE, uc2const.TYPE_CMYK_8, 4)
    except libcms.CmsError:
        return
    assert False
Ejemplo n.º 7
0
	def setUp(self):
		rgb_profile = get_filepath('sRGB.icm')
		self.inProfile = libcms.cms_open_profile_from_file(rgb_profile)
		cmyk_profile = get_filepath('GenericCMYK.icm')
		self.outProfile = libcms.cms_open_profile_from_file(cmyk_profile)
		self.transform = libcms.cms_create_transform(self.inProfile,
						uc2const.TYPE_RGBA_8, self.outProfile, uc2const.TYPE_CMYK_8,
						uc2const.INTENT_PERCEPTUAL, uc2const.cmsFLAGS_NOTPRECALC)
		self.transform2 = libcms.cms_create_transform(self.inProfile,
						uc2const.TYPE_RGBA_8, self.outProfile, uc2const.TYPE_CMYK_8,
						uc2const.INTENT_PERCEPTUAL, 0)
Ejemplo n.º 8
0
	def setUp(self):
		rgb_profile = os.path.join(_pkgdir, 'cms_data', 'sRGB.icm')
		self.inProfile = libcms.cms_open_profile_from_file(rgb_profile)
		cmyk_profile = os.path.join(_pkgdir, 'cms_data', 'GenericCMYK.icm')
		self.outProfile = libcms.cms_open_profile_from_file(cmyk_profile)
		self.transform = libcms.cms_create_transform(self.inProfile,
						uc2const.TYPE_RGBA_8, self.outProfile, uc2const.TYPE_CMYK_8,
						uc2const.INTENT_PERCEPTUAL, uc2const.cmsFLAGS_NOTPRECALC)
		self.transform2 = libcms.cms_create_transform(self.inProfile,
						uc2const.TYPE_RGBA_8, self.outProfile, uc2const.TYPE_CMYK_8,
						uc2const.INTENT_PERCEPTUAL, 0)
Ejemplo n.º 9
0
def test_create_transform_with_custom_intent():
    assert libcms.cms_create_transform(IN_PROFILE, uc2const.TYPE_RGB_8,
                                       OUT_PROFILE, uc2const.TYPE_CMYK_8,
                                       uc2const.INTENT_PERCEPTUAL) is not None
    assert libcms.cms_create_transform(
        IN_PROFILE, uc2const.TYPE_RGB_8, OUT_PROFILE, uc2const.TYPE_CMYK_8,
        uc2const.INTENT_RELATIVE_COLORIMETRIC) is not None
    assert libcms.cms_create_transform(IN_PROFILE, uc2const.TYPE_RGB_8,
                                       OUT_PROFILE, uc2const.TYPE_CMYK_8,
                                       uc2const.INTENT_SATURATION) is not None
    assert libcms.cms_create_transform(
        IN_PROFILE, uc2const.TYPE_RGB_8, OUT_PROFILE, uc2const.TYPE_CMYK_8,
        uc2const.INTENT_ABSOLUTE_COLORIMETRIC) is not None
Ejemplo n.º 10
0
def test_create_transform():
    assert libcms.cms_create_transform(IN_PROFILE, uc2const.TYPE_RGB_8,
                                       OUT_PROFILE,
                                       uc2const.TYPE_CMYK_8) is not None
    assert libcms.cms_create_transform(IN_PROFILE, uc2const.TYPE_RGBA_8,
                                       OUT_PROFILE,
                                       uc2const.TYPE_CMYK_8) is not None
    assert libcms.cms_create_transform(OUT_PROFILE, uc2const.TYPE_CMYK_8,
                                       IN_PROFILE,
                                       uc2const.TYPE_RGBA_8) is not None
    assert libcms.cms_create_transform(OUT_PROFILE, uc2const.TYPE_CMYK_8,
                                       IN_PROFILE,
                                       uc2const.TYPE_RGB_8) is not None
Ejemplo n.º 11
0
	def test05_create_transform_with_custom_intent(self):
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_PERCEPTUAL))
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_RELATIVE_COLORIMETRIC))
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_SATURATION))
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_ABSOLUTE_COLORIMETRIC))
Ejemplo n.º 12
0
	def test05_create_transform_with_custom_intent(self):
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_PERCEPTUAL))
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_RELATIVE_COLORIMETRIC))
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_SATURATION))
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_ABSOLUTE_COLORIMETRIC))
Ejemplo n.º 13
0
	def test06_create_transform_with_custom_flags(self):
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_PERCEPTUAL,
				uc2const.cmsFLAGS_NOTPRECALC | uc2const.cmsFLAGS_GAMUTCHECK))
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_PERCEPTUAL,
				uc2const.cmsFLAGS_PRESERVEBLACK | uc2const.cmsFLAGS_BLACKPOINTCOMPENSATION))
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_PERCEPTUAL,
				uc2const.cmsFLAGS_NOTPRECALC | uc2const.cmsFLAGS_HIGHRESPRECALC))
		self.assertNotEqual(None, libcms.cms_create_transform(self.inProfile,
				uc2const.TYPE_RGB_8, self.outProfile, uc2const.TYPE_CMYK_8,
				uc2const.INTENT_PERCEPTUAL,
				uc2const.cmsFLAGS_NOTPRECALC | uc2const.cmsFLAGS_LOWRESPRECALC))
Ejemplo n.º 14
0
def test_create_transform_with_custom_flags():
    assert libcms.cms_create_transform(
        IN_PROFILE, uc2const.TYPE_RGB_8, OUT_PROFILE, uc2const.TYPE_CMYK_8,
        uc2const.INTENT_PERCEPTUAL, uc2const.cmsFLAGS_NOTPRECALC
        | uc2const.cmsFLAGS_GAMUTCHECK) is not None
    assert libcms.cms_create_transform(
        IN_PROFILE, uc2const.TYPE_RGB_8, OUT_PROFILE, uc2const.TYPE_CMYK_8,
        uc2const.INTENT_PERCEPTUAL, uc2const.cmsFLAGS_PRESERVEBLACK
        | uc2const.cmsFLAGS_BLACKPOINTCOMPENSATION) is not None
    assert libcms.cms_create_transform(
        IN_PROFILE, uc2const.TYPE_RGB_8, OUT_PROFILE, uc2const.TYPE_CMYK_8,
        uc2const.INTENT_PERCEPTUAL, uc2const.cmsFLAGS_NOTPRECALC
        | uc2const.cmsFLAGS_HIGHRESPRECALC) is not None
    assert libcms.cms_create_transform(
        IN_PROFILE, uc2const.TYPE_RGB_8, OUT_PROFILE, uc2const.TYPE_CMYK_8,
        uc2const.INTENT_PERCEPTUAL, uc2const.cmsFLAGS_NOTPRECALC
        | uc2const.cmsFLAGS_LOWRESPRECALC) is not None
Ejemplo n.º 15
0
	def test33_get_embedded_profile(self):
		img = Image.open(get_filepath('CustomRGB.jpg'))
		profile = img.info.get('icc_profile')
		try:
			custom_profile = libcms.cms_open_profile_from_string(profile)
			transform = libcms.cms_create_transform(custom_profile,
							uc2const.TYPE_RGB_8, self.inProfile, uc2const.TYPE_RGB_8,
							uc2const.INTENT_PERCEPTUAL, uc2const.cmsFLAGS_NOTPRECALC)
			img2 = libcms.cms_do_bitmap_transform(transform,
										img, uc2const.TYPE_RGB_8, uc2const.TYPE_RGB_8)
		except libcms.CmsError:
			self.fail()
Ejemplo n.º 16
0
	def test33_get_embedded_profile(self):
		img = Image.open(get_filepath('CustomRGB.jpg'))
		profile = img.info.get('icc_profile')
		try:
			custom_profile = libcms.cms_open_profile_from_string(profile)
			transform = libcms.cms_create_transform(custom_profile,
							uc2const.TYPE_RGB_8, self.inProfile, uc2const.TYPE_RGB_8,
							uc2const.INTENT_PERCEPTUAL, uc2const.cmsFLAGS_NOTPRECALC)
			img2 = libcms.cms_do_bitmap_transform(transform,
										img, uc2const.TYPE_RGB_8, uc2const.TYPE_RGB_8)
		except libcms.CmsError:
			self.fail()
Ejemplo n.º 17
0
def test_get_embedded_profile():
    img = PIL.Image.open(get_filepath('CustomRGB.jpg'))
    profile = img.info.get('icc_profile')
    try:
        custom_profile = libcms.cms_open_profile_from_string(profile)
        transform = libcms.cms_create_transform(custom_profile,
                                                uc2const.TYPE_RGB_8,
                                                IN_PROFILE,
                                                uc2const.TYPE_RGB_8,
                                                uc2const.INTENT_PERCEPTUAL,
                                                uc2const.cmsFLAGS_NOTPRECALC)
        libcms.cms_do_bitmap_transform(transform, img, uc2const.TYPE_RGB_8,
                                       uc2const.TYPE_RGB_8)
    except libcms.CmsError:
        assert False
Ejemplo n.º 18
0
from uc2 import uc2const
from uc2.cms import libcms

_pkgdir = os.path.abspath(os.path.dirname(__file__))


def get_filepath(filename):
    return os.path.join(_pkgdir, 'cms_data', filename)


IN_PROFILE = libcms.cms_open_profile_from_file(get_filepath('sRGB.icm'))
OUT_PROFILE = libcms.cms_open_profile_from_file(
    get_filepath('GenericCMYK.icm'))
TRANSFORM = libcms.cms_create_transform(IN_PROFILE, uc2const.TYPE_RGBA_8,
                                        OUT_PROFILE, uc2const.TYPE_CMYK_8,
                                        uc2const.INTENT_PERCEPTUAL,
                                        uc2const.cmsFLAGS_NOTPRECALC)
TRANSFORM2 = libcms.cms_create_transform(IN_PROFILE, uc2const.TYPE_RGBA_8,
                                         OUT_PROFILE, uc2const.TYPE_CMYK_8,
                                         uc2const.INTENT_PERCEPTUAL, 0)


def test_open_invalid_profile():
    try:
        profile = get_filepath('empty.icm')
        libcms.cms_open_profile_from_file(profile)
    except libcms.CmsError:
        return
    assert False