Python 使用photoshop-python-API执行一个photoshop里面的动作
【代码】Python 使用photoshop-python-API执行一个photoshop里面的动作。
·
from photoshop import Session
import photoshop.api as ps
#执行动作
def execute_action(action_name,group_name):
with Session() as ps:
desc69=ps.ActionDescriptor
ref22=ps.ActionReference
idactn=ps.app.charIDToTypeID('Actn')
ref22.putName(idactn,action_name)
ref22.putName(ps.app.charIDToTypeID("ASet"),group_name)
desc69.putReference(ps.app.charIDToTypeID("null"),ref22)
ps.app.executeAction(ps.app.charIDToTypeID("Ply "),desc69,ps.DialogModes.DisplayNoDialogs)
#打开图片
def OpenPNG(path):
with Session(path, action="open") as ps:
ps.echo(ps.active_document.name)
#加载图片
def LoadPNG(path):
app = ps.Application()
app.load(path)
OpenPNG(path)
LoadPNG(r"D:\Pictures\1.png")
execute_action("ColorGradation","组 1")
print("执行动作完成")
更多推荐
所有评论(0)