在 Photoshop 中并使用 python,我无法将事件文档另存为 PSB(大文档格式)文件
使用 win32com.client,我可以将事件文档另存为 .psd 文件,如下所示:
from win32com.client import Dispatch
psApp = Dispatch("Photoshop.Application")
activeDocument = psApp.Application.ActiveDocument
activeDocument.SaveAs("E:\\PSDCopy", PhotoshopSaveOptions, False)
尽管我无法强制它另存为 psb,无论我如何尝试。 我在 VBScript 文档中也找不到任何线索,甚至连一个关于 psb 文件的字都找不到。
任何帮助将不胜感激。
最佳答案
Adobe 创建了一个糟糕的 API 用于与 Photoshop 交互。更糟糕的是,该文档已被弃用,并且不包含 PSB 文件、EXR 文件等更新。
了解如何为此编写代码的一个好方法是使用 Photoshop ActionListener 并破解您的方法(并不总是有效,但它为您提供了一些很好的线索)。您可以阅读更多相关信息here .
这应该符合您的要求:
import comtypes.client as ct
app = ct.CreateObject('Photoshop.Application')
def save_as_psb(path):
""" Save the current Document as PSB with maximised compatibility
turned ON.
Args:
path (str): This is the filename of the output PSB
"""
desc19 = ct.CreateObject("Photoshop.ActionDescriptor")
desc20 = ct.CreateObject("Photoshop.ActionDescriptor")
desc20.putBoolean(app.StringIDToTypeID('maximizeCompatibility'), True)
desc19.putObject(
app.CharIDToTypeID('As '), app.CharIDToTypeID('Pht8'), desc20)
desc19.putPath(app.CharIDToTypeID('In '), path)
logging.debug(path)
desc19.putBoolean(app.CharIDToTypeID('LwCs'), True)
app.executeAction(app.CharIDToTypeID('save'), desc19, 3)
关于python - 如何在 python 中使用 win32com.client 将文档另存为 .psb 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56113539/