def test_do_bitmap_transform(): in_image = PIL.Image.open(get_filepath('black100x100.png')) pixel = in_image.getpixel((1, 1)) assert 3 == len(pixel) out_image = libcms.cms_do_bitmap_transform(TRANSFORM2, in_image, uc2const.TYPE_RGB_8, uc2const.TYPE_CMYK_8) pixel = out_image.getpixel((1, 1)) assert 4 == len(pixel) in_image = PIL.Image.open(get_filepath('white100x100.png')) pixel = in_image.getpixel((1, 1)) assert 3 == len(pixel) out_image = libcms.cms_do_bitmap_transform(TRANSFORM2, in_image, uc2const.TYPE_RGB_8, uc2const.TYPE_CMYK_8) pixel = out_image.getpixel((1, 1)) assert 4 == len(pixel) in_image = PIL.Image.open(get_filepath('color100x100.png')) pixel = in_image.getpixel((1, 1)) assert 3 == len(pixel) out_image = libcms.cms_do_bitmap_transform(TRANSFORM2, in_image, uc2const.TYPE_RGB_8, uc2const.TYPE_CMYK_8) pixel = out_image.getpixel((1, 1)) assert 4 == len(pixel)
def test26_DoBitmapTransform(self): inImage = Image.open(get_filepath('black100x100.png')) pixel = inImage.getpixel((1, 1)) self.assertEqual(3, len(pixel)) outImage = libcms.cms_do_bitmap_transform(self.transform2, inImage, uc2const.TYPE_RGB_8, uc2const.TYPE_CMYK_8) pixel = outImage.getpixel((1, 1)) self.assertEqual(4, len(pixel)) inImage = Image.open(get_filepath('white100x100.png')) pixel = inImage.getpixel((1, 1)) self.assertEqual(3, len(pixel)) outImage = libcms.cms_do_bitmap_transform(self.transform2, inImage, uc2const.TYPE_RGB_8, uc2const.TYPE_CMYK_8) pixel = outImage.getpixel((1, 1)) self.assertEqual(4, len(pixel)) inImage = Image.open(get_filepath('color100x100.png')) pixel = inImage.getpixel((1, 1)) self.assertEqual(3, len(pixel)) outImage = libcms.cms_do_bitmap_transform(self.transform2, inImage, uc2const.TYPE_RGB_8, uc2const.TYPE_CMYK_8) pixel = outImage.getpixel((1, 1)) self.assertEqual(4, len(pixel))
def test_do_bitmap_transform_with_unsupported_out_mode(): in_image = PIL.Image.open(get_filepath('black100x100.png')) try: libcms.cms_do_bitmap_transform(TRANSFORM2, in_image, uc2const.TYPE_RGB_8, "YCbCr") except libcms.CmsError: return assert False
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
def test29_DoBitmapTransformWithUnsupportedOutMode(self): inImage = Image.open(get_filepath('black100x100.png')) try: outImage = libcms.cms_do_bitmap_transform(self.transform2, inImage, uc2const.TYPE_RGB_8, "YCbCr") except libcms.CmsError: return self.fail()
def test27_DoBitmapTransformWithUnsupportedImage(self): inImage = Image.open(get_filepath('black100x100.png')) inImage.load() inImage = inImage.convert("YCbCr") try: outImage = libcms.cms_do_bitmap_transform(self.transform2, inImage, uc2const.TYPE_RGB_8, uc2const.TYPE_CMYK_8) except libcms.CmsError: return self.fail()
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()