Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中转换ICC配置文件_Python_Python Imaging Library_Color Profile_Color Management - Fatal编程技术网

在Python中转换ICC配置文件

在Python中转换ICC配置文件,python,python-imaging-library,color-profile,color-management,Python,Python Imaging Library,Color Profile,Color Management,我有一堆带有嵌入式icc颜色配置文件的png图像。当我加载并显示它们时,颜色是错误的,我理解这是因为没有考虑颜色配置文件信息。所以我要做的是将数据中的像素转换为sRGB,并丢弃图像中的配置文件信息。这将在屏幕上以正确的颜色显示它们 我在这里找到了一个脚本: 我将其改编为以下Python脚本: from PIL.ImageCms import profileToProfile from PIL import Image from sys import argv ADOBE_RGB_PROFILE

我有一堆带有嵌入式icc颜色配置文件的png图像。当我加载并显示它们时,颜色是错误的,我理解这是因为没有考虑颜色配置文件信息。所以我要做的是将数据中的像素转换为sRGB,并丢弃图像中的配置文件信息。这将在屏幕上以正确的颜色显示它们

我在这里找到了一个脚本:

我将其改编为以下Python脚本:

from PIL.ImageCms import profileToProfile
from PIL import Image
from sys import argv

ADOBE_RGB_PROFILE = "AdobeRGB1998.icc"
SRGB_PROFILE = "sRGB.icc"

def main(src, dst):
    original_image = Image.open(src)
    if 'icc_profile' in original_image.info:
        print "converting..."
        converted_image = profileToProfile(original_image, ADOBE_RGB_PROFILE, SRGB_PROFILE)
        print "saving file..."
        converted_image.save(dst)
        print "ok."

if __name__ == "__main__":
    main(argv[1], argv[2])
但它不起作用。生成的图像只是保持透明


所以我的问题是,如何在Python中使用嵌入的颜色配置文件转换图像?如果您可以修复我的脚本,或者编写一个新的脚本来实现上述代码的目的,那将非常棒。

我认为基于此的脚本中存在一个bug。如果原始图像中有“icc\U配置文件”,则会显示
。信息:
,但在下面的注释中,是说当图像已经有配置文件时,不应执行此操作!我认为你基于此的脚本中有一个bug。如果原始图像中有“icc\U配置文件”,则会显示
。信息:
,但在下面的注释中,是说当图像已经有配置文件时,不应执行此操作!