2012-12-12 65 views
2

我想將4個tif合併在一起形成一個CMYK圖像。使用image.merge合併tif圖像

這是代碼,我到目前爲止有: -

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' 

任何想法,將不勝感激

回答

1

mc這給了我一個錯誤,yk需要是PILImage對象,例如

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