的Photoshop在打開PDF文檔選項,叫做Photoshop.PDFOpenOptions
您需要win32com派遣的Photoshop應用。請參閱下面的示例代碼
import win32com.client
import os, glob
folderin = r'D:\in'
if (__name__ == '__main__'):
psApp = win32com.client.Dispatch('Photoshop.Application')
for infile in glob.glob(os.path.join(folderin, '*.pdf')):
options = win32com.client.Dispatch('Photoshop.PDFOpenOptions')
options.CropPage = 0 # BoundingBox
options.Resolution = 300 # Pixels
options.Mode = 1 # Grayscale
options.BitsPerChannel = 8 # 8 bits per channel
options.AntiAlias = True
options.ConstrainProportions = True #Deprecated for Adobe Photoshop CS3
doc = psApp.Open(infile, options)
doc.flatten
doc.Trim(1)
doc.Close(2)
psApp.Quit()
不能只使用''subprocess.call()''執行Photoshop並傳遞PDF作爲參數? – BeRecursive
@BeRecursive你可以像這樣從命令行啓動photoshop嗎? –
環境變量的路徑必須有photoshop目錄的路徑嗎?我試圖添加它,然後嘗試使用命令行打開Photoshop,並沒有奏效。 – csterling