文章目录
1.插件界面2.关键代码2.1.存为Web所用格式2.2.另存为3.代码转执行4.作者答疑PS是一款栅格图像编辑软件,具有许多强大的功能,本文演示如何通过脚本实现存为Web所用格式和另存为相关功能,展示从互联网收集而来的一个小插件,供大家学习交流,请勿用于商业用途。
1.插件界面
本文界面是一系列功能的一部分,将逐步展示,但是功能界面是共同的,如下图所示:
2.关键代码
2.1.存为Web所用格式
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
ErrStrs = {};ErrStrs.USER_CANCELLED = localize("$$$/ScriptingSupport/Error/UserCancelled=User cancelled the operation");try {var idslct = charIDToTypeID('slct');var desc1090 = new ActionDescriptor();var idnull = charIDToTypeID('null');var ref877 = new ActionReference();var idMnspsp = charIDToTypeID('Mn ');var idMnIt = charIDToTypeID('MnIt');var idSvfw = charIDToTypeID('Svfw');ref877.putEnumerated(idMnspsp, idMnIt, idSvfw);desc1090.putReference(idnull, ref877);executeAction(idslct, desc1090, DialogModes.ALL);} catch (e) {if (e.toString().indexOf(ErrStrs.USER_CANCELLED) != -1) {;} else {alert(localize("$$$/ScriptingSupport/Error/CommandNotAvailable=The command is currently not available"));}}
2.2.另存为
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
ErrStrs = {};ErrStrs.USER_CANCELLED = localize("$$$/ScriptingSupport/Error/UserCancelled=User cancelled the operation");try {var idsave = charIDToTypeID('save');var desc1092 = new ActionDescriptor();var idCpysp = charIDToTypeID('Cpy ');desc1092.putBoolean(idCpysp, true);executeAction(idsave, desc1092, DialogModes.ALL);} catch (e) {if (e.toString().indexOf(ErrStrs.USER_CANCELLED) != -1) {;} else {alert(localize("$$$/ScriptingSupport/Error/CommandNotAvailable=The command is currently not available"));}}
3.代码转执行
使用记事本或者notepad++等文本编辑器,将代码拷贝至文本文件,然后修改后缀名为js或者jsx,最后再PS软件菜单文件》脚本》浏览,点执行即可,也可以将脚本放在预设文件夹内,会显示再脚本下的二级子菜单。如下图所示:
4.作者答疑
如有疑问,请留言。
如果觉得《Photoshop插件-保存-存为Web所用格式-另存为-脚本开发-PS插件》对你有帮助,请点赞、收藏,并留下你的观点哦!