簡體   English   中英

如何在python中使用win32com.client將文檔另存為.psb文件?

[英]How can I save as the document as .psb file using win32com.client in python?

在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並逐步解決(不一定總是有效,但它會給您帶來一些好的線索)。 您可以在此處了解更多信息。

這應該可以滿足您的需求:

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM