Пример #1
0
def test_intent():
    skip_missing()
    assert ImageCms.getDefaultIntent(SRGB) == 0
    support = ImageCms.isIntentSupported(SRGB,
                                         ImageCms.INTENT_ABSOLUTE_COLORIMETRIC,
                                         ImageCms.DIRECTION_INPUT)
    assert support == 1
 def test_intent(self):
     self.skip_missing()
     self.assertEqual(ImageCms.getDefaultIntent(SRGB), 0)
     self.assertEqual(
         ImageCms.isIntentSupported(SRGB,
                                    ImageCms.INTENT_ABSOLUTE_COLORIMETRIC,
                                    ImageCms.DIRECTION_INPUT), 1)
Пример #3
0
def test_intent():
    skip_missing()
    assert ImageCms.getDefaultIntent(SRGB) == 0
    support = ImageCms.isIntentSupported(
        SRGB, ImageCms.Intent.ABSOLUTE_COLORIMETRIC, ImageCms.Direction.INPUT
    )
    assert support == 1
Пример #4
0
 def test_profile_object(self):
     # same, using profile object
     p = ImageCms.createProfile("sRGB")
 #    self.assertEqual(ImageCms.getProfileName(p).strip(),
 #                 'sRGB built-in - (lcms internal)')
 #    self.assertEqual(ImageCms.getProfileInfo(p).splitlines(),
 #             ['sRGB built-in', '', 'WhitePoint : D65 (daylight)', '', ''])
     self.assertEqual(ImageCms.getDefaultIntent(p), 0)
     self.assertEqual(ImageCms.isIntentSupported(
         p, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC,
         ImageCms.DIRECTION_INPUT), 1)
Пример #5
0
def test_profile_object():
    # same, using profile object
    p = ImageCms.createProfile("sRGB")
#    assert_equal(ImageCms.getProfileName(p).strip(),
#                 'sRGB built-in - (lcms internal)')
#    assert_equal(ImageCms.getProfileInfo(p).splitlines(),
#                 ['sRGB built-in', '', 'WhitePoint : D65 (daylight)', '', ''])
    assert_equal(ImageCms.getDefaultIntent(p), 0)
    assert_equal(ImageCms.isIntentSupported(
            p, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC,
            ImageCms.DIRECTION_INPUT), 1)
Пример #6
0
def test_profile_object():
    # same, using profile object
    p = ImageCms.createProfile("sRGB")
    # assert ImageCms.getProfileName(p).strip() == "sRGB built-in - (lcms internal)"
    # assert ImageCms.getProfileInfo(p).splitlines() ==
    #     ["sRGB built-in", "", "WhitePoint : D65 (daylight)", "", ""]
    assert ImageCms.getDefaultIntent(p) == 0
    support = ImageCms.isIntentSupported(p,
                                         ImageCms.INTENT_ABSOLUTE_COLORIMETRIC,
                                         ImageCms.DIRECTION_INPUT)
    assert support == 1
Пример #7
0
 def test_intent(self):
     self.skip_missing()
     self.assertEqual(ImageCms.getDefaultIntent(SRGB), 0)
     self.assertEqual(ImageCms.isIntentSupported(
         SRGB, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC,
         ImageCms.DIRECTION_INPUT), 1)
Пример #8
0
if TEST_getProfileInfo == True:
    # get a profile handle
    profile = ImageCms.getOpenProfile(INPUT_PROFILE)
    
    # lets print some info about our input profile:
    print("Profile name (retrieved from profile string path name): %s" %ImageCms.getProfileName(INPUT_PROFILE))

    # or, you could do the same thing using a profile handle as the arg
    print("Profile name (retrieved from profile handle): %s" %ImageCms.getProfileName(profile))

    # now lets get the embedded "info" tag contents
    # once again, you can use a path to a profile, or a profile handle
    print("Profile info (retrieved from profile handle): %s" %ImageCms.getProfileInfo(profile))

    # and what's the default intent of this profile?
    print("The default intent is (this will be an integer): %d" %(ImageCms.getDefaultIntent(profile)))

    # Hmmmm... but does this profile support INTENT_ABSOLUTE_COLORIMETRIC?
    print("Does it support INTENT_ABSOLUTE_COLORIMETRIC?: (1 is yes, -1 is no): %s" \
            %ImageCms.isIntentSupported(profile, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC, \
            ImageCms.DIRECTION_INPUT))    

    print("getProfileInfo test completed successfully.")

if TEST_misc == True:
    # test the versions, about, and copyright functions
    print("Versions: %s" %str(ImageCms.versions()))
    print("About:\n\n%s" %ImageCms.about())
    print("Copyright:\n\n%s" %ImageCms.copyright())

    print("misc test completed successfully.")
Пример #9
0
def test_sanity():

    # basic smoke test.
    # this mostly follows the cms_test outline.

    v = ImageCms.versions()  # should return four strings
    assert_equal(v[0], '0.1.0 pil')
    assert_equal(map(type, v), [str, str, str, str])

    # internal version number
    assert_match(ImageCms.core.littlecms_version, "\d+\.\d+$")

    i = ImageCms.profileToProfile(lena(), SRGB, SRGB)
    assert_image(i, "RGB", (128, 128))

    t = ImageCms.buildTransform(SRGB, SRGB, "RGB", "RGB")
    i = ImageCms.applyTransform(lena(), t)
    assert_image(i, "RGB", (128, 128))

    p = ImageCms.createProfile("sRGB")
    o = ImageCms.getOpenProfile(SRGB)
    t = ImageCms.buildTransformFromOpenProfiles(p, o, "RGB", "RGB")
    i = ImageCms.applyTransform(lena(), t)
    assert_image(i, "RGB", (128, 128))

    t = ImageCms.buildProofTransform(SRGB, SRGB, SRGB, "RGB", "RGB")
    assert_equal(t.inputMode, "RGB")
    assert_equal(t.outputMode, "RGB")
    i = ImageCms.applyTransform(lena(), t)
    assert_image(i, "RGB", (128, 128))

    # get profile information for file
    assert_equal(
        ImageCms.getProfileName(SRGB).strip(),
        'IEC 61966-2.1 Default RGB colour space - sRGB')
    assert_equal(
        ImageCms.getProfileInfo(SRGB).splitlines(), [
            'sRGB IEC61966-2.1', '',
            'Copyright (c) 1998 Hewlett-Packard Company', '',
            'WhitePoint : D65 (daylight)', '', 'Tests/icc/sRGB.icm'
        ])
    assert_equal(ImageCms.getDefaultIntent(SRGB), 0)
    assert_equal(
        ImageCms.isIntentSupported(SRGB, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC,
                                   ImageCms.DIRECTION_INPUT), 1)

    # same, using profile object
    p = ImageCms.createProfile("sRGB")
    assert_equal(
        ImageCms.getProfileName(p).strip(), 'sRGB built-in - (lcms internal)')
    assert_equal(
        ImageCms.getProfileInfo(p).splitlines(),
        ['sRGB built-in', '', 'WhitePoint : D65 (daylight)', '', ''])
    assert_equal(ImageCms.getDefaultIntent(p), 0)
    assert_equal(
        ImageCms.isIntentSupported(p, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC,
                                   ImageCms.DIRECTION_INPUT), 1)

    # extensions
    i = Image.open("Tests/images/rgb.jpg")
    p = ImageCms.getOpenProfile(StringIO(i.info["icc_profile"]))
    assert_equal(
        ImageCms.getProfileName(p).strip(),
        'IEC 61966-2.1 Default RGB colour space - sRGB')

    # the procedural pyCMS API uses PyCMSError for all sorts of errors
    assert_exception(ImageCms.PyCMSError,
                     lambda: ImageCms.profileToProfile(lena(), "foo", "bar"))
    assert_exception(
        ImageCms.PyCMSError,
        lambda: ImageCms.buildTransform("foo", "bar", "RGB", "RGB"))
    assert_exception(ImageCms.PyCMSError,
                     lambda: ImageCms.getProfileName(None))
    assert_exception(ImageCms.PyCMSError,
                     lambda: ImageCms.isIntentSupported(SRGB, None, None))

    # test PointTransform convenience API
    im = lena().point(t)

    # try fetching the profile for the current display device
    assert_no_exception(lambda: ImageCms.get_display_profile())
Пример #10
0
def test_intent():
    assert_equal(ImageCms.getDefaultIntent(SRGB), 0)
    assert_equal(ImageCms.isIntentSupported(
            SRGB, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC,
            ImageCms.DIRECTION_INPUT), 1)
Пример #11
0
def test_sanity():

    # basic smoke test.
    # this mostly follows the cms_test outline.

    v = ImageCms.versions() # should return four strings
    assert_equal(v[0], '0.1.0 pil')
    assert_equal(list(map(type, v)), [str, str, str, str])

    # internal version number
    assert_match(ImageCms.core.littlecms_version, "\d+\.\d+$")

    i = ImageCms.profileToProfile(lena(), SRGB, SRGB)
    assert_image(i, "RGB", (128, 128))

    t = ImageCms.buildTransform(SRGB, SRGB, "RGB", "RGB")
    i = ImageCms.applyTransform(lena(), t)
    assert_image(i, "RGB", (128, 128))

    p = ImageCms.createProfile("sRGB")
    o = ImageCms.getOpenProfile(SRGB)
    t = ImageCms.buildTransformFromOpenProfiles(p, o, "RGB", "RGB")
    i = ImageCms.applyTransform(lena(), t)
    assert_image(i, "RGB", (128, 128))

    t = ImageCms.buildProofTransform(SRGB, SRGB, SRGB, "RGB", "RGB")
    assert_equal(t.inputMode, "RGB")
    assert_equal(t.outputMode, "RGB")
    i = ImageCms.applyTransform(lena(), t)
    assert_image(i, "RGB", (128, 128))

    # get profile information for file
    assert_equal(ImageCms.getProfileName(SRGB).strip(),
                 'IEC 61966-2.1 Default RGB colour space - sRGB')
    assert_equal(ImageCms.getProfileInfo(SRGB).splitlines(),
                 ['sRGB IEC61966-2.1', '',
                  'Copyright (c) 1998 Hewlett-Packard Company', '',
                  'WhitePoint : D65 (daylight)', '',
                  'Tests/icc/sRGB.icm'])
    assert_equal(ImageCms.getDefaultIntent(SRGB), 0)
    assert_equal(ImageCms.isIntentSupported(
            SRGB, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC,
            ImageCms.DIRECTION_INPUT), 1)

    # same, using profile object
    p = ImageCms.createProfile("sRGB")
    assert_equal(ImageCms.getProfileName(p).strip(),
                 'sRGB built-in - (lcms internal)')
    assert_equal(ImageCms.getProfileInfo(p).splitlines(),
                 ['sRGB built-in', '', 'WhitePoint : D65 (daylight)', '', ''])
    assert_equal(ImageCms.getDefaultIntent(p), 0)
    assert_equal(ImageCms.isIntentSupported(
            p, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC,
            ImageCms.DIRECTION_INPUT), 1)

    # extensions
    i = Image.open("Tests/images/rgb.jpg")
    p = ImageCms.getOpenProfile(BytesIO(i.info["icc_profile"]))
    assert_equal(ImageCms.getProfileName(p).strip(),
                 'IEC 61966-2.1 Default RGB colour space - sRGB')

    # the procedural pyCMS API uses PyCMSError for all sorts of errors
    assert_exception(ImageCms.PyCMSError, lambda: ImageCms.profileToProfile(lena(), "foo", "bar"))
    assert_exception(ImageCms.PyCMSError, lambda: ImageCms.buildTransform("foo", "bar", "RGB", "RGB"))
    assert_exception(ImageCms.PyCMSError, lambda: ImageCms.getProfileName(None))
    assert_exception(ImageCms.PyCMSError, lambda: ImageCms.isIntentSupported(SRGB, None, None))

    # test PointTransform convenience API
    im = lena().point(t)

    # try fetching the profile for the current display device
    assert_no_exception(lambda: ImageCms.get_display_profile())
Пример #12
0
    # lets print some info about our input profile:
    print "Profile name (retrieved from profile string path name): %s" % ImageCms.getProfileName(
        INPUT_PROFILE)

    # or, you could do the same thing using a profile handle as the arg
    print "Profile name (retrieved from profile handle): %s" % ImageCms.getProfileName(
        profile)

    # now lets get the embedded "info" tag contents
    # once again, you can use a path to a profile, or a profile handle
    print "Profile info (retrieved from profile handle): %s" % ImageCms.getProfileInfo(
        profile)

    # and what's the default intent of this profile?
    print "The default intent is (this will be an integer): %d" % (
        ImageCms.getDefaultIntent(profile))

    # Hmmmm... but does this profile support INTENT_ABSOLUTE_COLORIMETRIC?
    print "Does it support INTENT_ABSOLUTE_COLORIMETRIC?: (1 is yes, -1 is no): %s" \
            %ImageCms.isIntentSupported(profile, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC, \
            ImageCms.DIRECTION_INPUT)

    print "getProfileInfo test completed successfully."

if TEST_misc == True:
    # test the versions, about, and copyright functions
    print "Versions: %s" % str(ImageCms.versions())
    print "About:\n\n%s" % ImageCms.about()
    print "Copyright:\n\n%s" % ImageCms.copyright()

    print "misc test completed successfully."
Пример #13
0
if TEST_getProfileInfo:
    # get a profile handle
    profile = ImageCms.getOpenProfile(INPUT_PROFILE)

    # lets print some info about our input profile:
    print("Profile name (retrieved from profile string path name): %s" %ImageCms.getProfileName(INPUT_PROFILE))

    # or, you could do the same thing using a profile handle as the arg
    print("Profile name (retrieved from profile handle): %s" %ImageCms.getProfileName(profile))

    # now lets get the embedded "info" tag contents
    # once again, you can use a path to a profile, or a profile handle
    print("Profile info (retrieved from profile handle): %s" %ImageCms.getProfileInfo(profile))

    # and what's the default intent of this profile?
    print("The default intent is (this will be an integer): %d" %(ImageCms.getDefaultIntent(profile)))

    # Hmmmm... but does this profile support INTENT_ABSOLUTE_COLORIMETRIC?
    print("Does it support INTENT_ABSOLUTE_COLORIMETRIC?: (1 is yes, -1 is no): %s" \
            %ImageCms.isIntentSupported(profile, ImageCms.INTENT_ABSOLUTE_COLORIMETRIC, \
            ImageCms.DIRECTION_INPUT))

    print("getProfileInfo test completed successfully.")

if TEST_misc:
    # test the versions, about, and copyright functions
    print("Versions: %s" %str(ImageCms.versions()))
    print("About:\n\n%s" %ImageCms.about())
    print("Copyright:\n\n%s" %ImageCms.copyright())

    print("misc test completed successfully.")