当前位置:   article > 正文

Python 使用photoshop-python-API执行一个photoshop里面的动作

photoshop-python-api
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("执行动作完成")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/110310
推荐阅读
相关标签
  

闽ICP备14008679号