文章目录
PS是一款栅格图像编辑软件,具有许多强大的功能,本文演示如何通过脚本新建文档,嵌入智能对象和复制图像,展示从互联网收集而来的一个小插件,供大家学习交流,请勿用于商业用途。
1.插件界面
-
- 1.插件界面
- 2.关键代码
-
- 2.1新建文档
- 2.2嵌入智能对象
- 2.3复制图像
- 3.作者寄语
本文界面是一系列功能的一部分,将逐步展示,但是功能界面是共同的,如下图所示:
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
ErrStrs = {}; ErrStrs.USER_CANCELLED = localize("$$$/ScriptingSupport/Error/UserCancelled=用户取消了操作"); try { var idMkspsp = charIDToTypeID('Mk '); var desc1100 = new ActionDescriptor(); var idNwspsp = charIDToTypeID('Nw '); var idDcmn = charIDToTypeID('Dcmn'); desc1100.putClass(idNwspsp, idDcmn); executeAction(idMkspsp, desc1100, DialogModes.ALL); } catch (e) { if (e.toString().indexOf(ErrStrs.USER_CANCELLED) != -1) { ; } else { alert(localize("$$$/ScriptingSupport/Error/CommandNotAvailable=该命令当前不可用")); } }2.2嵌入智能对象
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
ErrStrs = {}; ErrStrs.USER_CANCELLED = localize("$$$/ScriptingSupport/Error/UserCancelled=用户取消了操作"); try { var idslct = charIDToTypeID('slct'); var desc1089 = new ActionDescriptor(); var idnull = charIDToTypeID('null'); var ref876 = new ActionReference(); var idMnspsp = charIDToTypeID('Mn '); var idMnIt = charIDToTypeID('MnIt'); var idPlce = charIDToTypeID('Plce'); ref876.putEnumerated(idMnspsp, idMnIt, idPlce); desc1089.putReference(idnull, ref876); executeAction(idslct, desc1089, DialogModes.ALL); } catch (e) { if (e.toString().indexOf(ErrStrs.USER_CANCELLED) != -1) { ; } else { alert(localize("$$$/ScriptingSupport/Error/CommandNotAvailable=该命令当前不可用")); } }2.3复制图像
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
ErrStrs = {}; ErrStrs.USER_CANCELLED = localize("$$$/ScriptingSupport/Error/UserCancelled=用户取消了操作"); try { var idDplc = charIDToTypeID('Dplc'); var desc843 = new ActionDescriptor(); var idnull = charIDToTypeID('null'); var ref713 = new ActionReference(); var idDcmn = charIDToTypeID('Dcmn'); var idOrdn = charIDToTypeID('Ordn'); var idFrst = charIDToTypeID('Frst'); ref713.putEnumerated(idDcmn, idOrdn, idFrst); desc843.putReference(idnull, ref713); executeAction(idDplc, desc843, DialogModes.ALL); } catch (e) { if (e.toString().indexOf(ErrStrs.USER_CANCELLED) != -1) { ; } else { alert(localize("$$$/ScriptingSupport/Error/CommandNotAvailable=该命令当前不可用")); } }3.作者寄语
合理的脚本代码可以有效的提高工作效率,减少重复劳动。
文章引用至 作者知了-联系方式1
文章引用至 作者知了-联系方式2