打开jpg图像时改变颜色

Changing colors when jpg image is opened

我首先将这张图片保存到我的本地机器上:http://imgur.com/w3uQ9Ra

然后我尝试用这段代码打开并显示它:

from PIL import Image
img = Image.open('gipsy1.jpg')
img.show()

show 显示的图像(或保存到新文件中的图像)与原始文件略有不同,可以在此处查看:http://imgur.com/9TAPiqx。有什么办法可以避免这种情况吗?

关于我的环境的一些信息:

郑重声明:此图像使用 ICC Display P3 space,它仅在新的 Apple 产品和其他一些高端显示器上受支持。如果我们强制 ICC 为 sRGB,我们会得到更好的结果。

以下代码工作正常:

from PIL import Image
img = Image.open('gipsy1.jpg')
import tempfile
from PIL import ImageCms
icc = tempfile.mkstemp(suffix='.icc')[1]
with open(icc, 'w') as f:
f.write(img.info.get('icc_profile'))
srgb = ImageCms.createProfile('sRGB')
img = ImageCms.profileToProfile(img, icc, srgb)
img.save('new_srgb_gipsy1.jpg')