Python 我的脚本有什么问题,将psd导出为bmp?

Python 我的脚本有什么问题,将psd导出为bmp?,python,export,photoshop,bmp,Python,Export,Photoshop,Bmp,我正在尝试将psd文件导出到bmp 如果我在这里删除这一行,它将正确地生成test.png, 但我想得到bmp文件 如果我在这里使用####,我会得到“AttributeError:Property'Photoshop.bmpsavepoptions.Format'无法设置” 如果我正确地阅读了您的问题(如果我没有,请道歉),您希望以BMP而不是PNG格式保存文件。我猜你需要更改选项。格式 options.Format=13#PNG 经过一些研究,BMP看起来是2,因此我将您的代码更改为: op

我正在尝试将psd文件导出到bmp

如果我在这里删除这一行,它将正确地生成test.png, 但我想得到bmp文件

如果我在这里使用####,我会得到“AttributeError:Property'Photoshop.bmpsavepoptions.Format'无法设置”


如果我正确地阅读了您的问题(如果我没有,请道歉),您希望以BMP而不是PNG格式保存文件。我猜你需要更改选项。格式

options.Format=13#PNG

经过一些研究,BMP看起来是2,因此我将您的代码更改为:

options.Format=2#BMP

请注意,我还建议您在保存文件时更改文件名,以避免混淆。也许是这个


fn=os.path.splitext(fk)[0]+''.'+fn+'.bmp'

如果我正确阅读了您的问题(如果我没有阅读,请说明),您希望以bmp而不是PNG格式保存文件。我猜你需要更改选项。格式

options.Format=13#PNG

经过一些研究,BMP看起来是2,因此我将您的代码更改为:

options.Format=2#BMP

请注意,我还建议您在保存文件时更改文件名,以避免混淆。也许是这个


fn=os.path.splitext(fk)[0]+''.'+fn+'.bmp'

提问前请先回答这个问题。这将使您的问题更有效。您正在传递
Options=self.Options
,但只使用
Options=win32com.client.Dispatch('Photoshop.bmpsavepoptions')
语句定义一个局部变量。是的,我现在修改它。非常感谢。在提问之前请先回答这个问题。这将使您的问题更有效。您正在传递
Options=self.Options
,但只使用
Options=win32com.client.Dispatch('Photoshop.bmpsavepoptions')
语句定义一个局部变量。是的,我现在修改它。非常感谢。谢谢,如果我修改它:options.Format=2#BMP,AttributeError:Property“Photoshop.bmpsavepoptions.Format”无法设置。我可能只对了一半。试试这个。而不是这个-
options=win32com.client.Dispatch('Photoshop.exportoptionsaveforweb')
options.Format=13 35; PNG
options.PNG8=False#将其设置为PNG-24位
试试这个:
options=win32.Dispatch(“Photoshop.BMPSaveOptions”)
options.Format=2
我通过引用解决了它:,使用doc.SaveAs(fn,options,True),ok!谢谢你,如果我修改它:options.Format=2#BMP,AttributeError:Property'Photoshop.bmpsavepoptions.Format'无法设置。我可能只对了一半。试试这个。而不是这个-
options=win32com.client.Dispatch('Photoshop.exportoptionsaveforweb')
options.Format=13 35; PNG
options.PNG8=False#将其设置为PNG-24位
试试这个:
options=win32.Dispatch(“Photoshop.BMPSaveOptions”)
options.Format=2
我通过引用解决了它:,使用doc.SaveAs(fn,options,True),ok!呵呵
import win32com.client
import os

fn='test.psd'
psApp = win32com.client.Dispatch('Photoshop.Application')
options = win32com.client.Dispatch('Photoshop.ExportOptionsSaveForWeb')
options.Format = 13         # PNG
options.PNG8 = False        # Sets it to PNG-24 bit
#options = win32com.client.Dispatch('Photoshop.BMPSaveOptions') ###here del
#options.Format = 2         # bmp
#
fd=os.path.abspath('.')
fk=os.path.join(fd, fn)
doc = psApp.Open(fk)
fn='BBB'
fn = os.path.splitext(fk)[0] + '_' + fn + '.png'
#fn = os.path.splitext(fk)[0] + '_' + fn + '.bmp'  ###
doc.Export(ExportIn=fn, ExportAs=2,  Options=options) #ExportAs=2,
doc.Close(2)