gpt4 book ai didi

python - 使用 image.merge 合并 tif 图像

转载 作者:太空宇宙 更新时间:2023-11-04 06:18:44 25 4
gpt4 key购买 nike

我正在尝试将 4 个 tif 合并在一起以形成 CMYK 图像。

这是我目前的代码:-

import Image

m = "C:\Documents and Settings\dbigwood\Desktop\TEST\magnew.tif"
c = "C:\Documents and Settings\dbigwood\Desktop\TEST\cyannew.tif"
y = "C:\Documents and Settings\dbigwood\Desktop\TEST\yellownew.tif"
k = "C:\Documents and Settings\dbigwood\Desktop\TEST\knew.tif"

im = Image.merge("CMYK",(c,m,y,k))

im.save("C:\Documents and Settings\dbigwood\Desktop\TEST\AAA.tif")

运行时报错

Traceback (most recent call last):
File "C:\Documents and Settings\dbigwood\Desktop\TEST\try5.py", line 18, in <module>
im = Image.merge("CMYK",(c,m,y,k))
File "C:\Python26\ArcGIS10.0\lib\site-packages\PIL\Image.py", line 1996, in merge
if im.mode != getmodetype(mode):
AttributeError: 'str' object has no attribute 'mode'

任何想法将不胜感激

最佳答案

m, c, y and k 需要是PIL Image 对象,例如

m = Image.open("C:\Documents and Settings\dbigwood\Desktop\TEST\magnew.tif")

关于python - 使用 image.merge 合并 tif 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13839654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com