1
Photoshop中TIFF處理我需要編寫一個腳本,執行以下操作:基本與使用python
# open a tiff
# get it's dpi, width, height and colorspace
# set the dpi, width, height and colorspace
# and then save the tiff out with no compression and no layers.
到目前爲止,我已經得到了:
from win32com.client.dynamic import Dispatch
ps = Dispatch("Photoshop.Application")
file_path = "C:\\Users\\me\\myImg.tif"
doc = ps.Open(file_path)
dpi = doc.Resolution
width = doc.Width # in cm
height = doc.Height # in cm
# up to here the code works, but then I try
doc.Resolution = 72
ps.ResizeImage(120 , 120)
ps.PsColorSpaceType(3) # psSRGB
ps.TiffSaveOptions.ImageCompression = 1 # psNoTIFFCompression
ps.TiffSaveOptions.Layers = False
ps.Save()
# and this last section fails
請幫助,任何想法,提示,soultions將不勝感激:D
你能提供輸出的地方 '炸彈'?沒有人知道這意味着什麼。出於好奇,你能夠使用PIL還是你綁定到Photoshop? – jdi 2012-02-10 15:07:40
炸彈意味着失敗/出錯,抱歉。我試過PIL,它甚至無法正確讀取tiff。在一些論壇中,人們建議嘗試一種圖像處理模塊/庫等的變體,但是它們都沒有100%成功,即每個模塊總是有幾個tiffs無法讀取。然而,Photoshop可以打開所有不同種類的TIFF,而我們的工作室有一個備用的Photoshop許可證,這就是爲什麼我選擇使用Photoshop。我也嘗試過ImageMagik,但是它也不適用於幾個tiff。 – Jared 2012-02-11 16:35:55
關於提供輸出失敗的地方,註釋「#代碼到這裏代碼有效,但我嘗試 」後面的命令是我希望腳本執行的更多示例,而不是實際正確的命令。他們是我拼湊在一起的點點滴滴,展示了我正在努力實現的目標。我之前沒有通過Python使用過Photoshop,所以我真的不知道該怎麼做。感謝您花時間閱讀我的問題,雖然:) – Jared 2012-02-11 16:38:48