编程语言/photoshop:修订间差异
来自康健生活
| (未显示同一用户的46个中间版本) | |||
| 第3行: | 第3行: | ||
{{Unknown|Adobe-CEP / CEP-Resources}} | {{Unknown|Adobe-CEP / CEP-Resources}} | ||
== 扩展文件夹 == | |||
扩展文件夹所在位置。加载顺序为产品扩展、系统扩展、用户扩展。 | |||
产品扩展。 | |||
* <code>${PP}/CEP/extensions</code>。 | |||
系统扩展。 | |||
* window x86: <code>C:\Program Files\Common Files\Adobe\CEP\extensions</code>。 | |||
* window x64: | |||
: <code>C:\Program Files (x86)\Common Files\Adobe\CEP\extensions</code>。 | |||
: <code>C:\Program Files\Common Files\Adobe\CEP\extensions</code>。 | |||
* mac: <code>/Library/Application Support/Adobe/CEP/extensions</code>。 | |||
用户扩展。 | |||
* window: <code>C:\Users\<USERNAME>\AppData\Roaming\Adobe\CEP/extensions</code>。 | |||
* mac: <code>~/Library/Application Support/Adobe/CEP/extensions</code>。 | |||
== 开发流程 == | == 开发流程 == | ||
开发模式判断 | 开发模式判断 | ||
| 第12行: | 第28行: | ||
== 日志 == | == 日志 == | ||
=== 日志位置 === | |||
日志文件所在位置。 | |||
* window: <code>C:\Users\<USERNAME>\AppData\Local\Temp</code>。 | |||
* mac: <code>/Users/<USERNAME>/Library/Logs/CSXS</code>。 | |||
=== CEF日志 === | === CEF日志 === | ||
| 第17行: | 第38行: | ||
<pre> | <pre> | ||
C:\Users\365\AppData\Local\Temp\CEP7-PHXS.log</pre> | C:\Users\365\AppData\Local\Temp\CEP7-PHXS.log</pre> | ||
==== CEP缓存清理 ==== | |||
=== CEPHtmlEngine日志 === | === CEPHtmlEngine日志 === | ||
| 第37行: | 第60行: | ||
* Vulcan.js | * Vulcan.js | ||
== ExtendScript == | == ExtendScript == | ||
=== | === 打印 === | ||
使用 <code>$.writeln()</code> 与 <code>$.write()</code>。 | 使用 <code>$.writeln()</code> 与 <code>$.write()</code>。 | ||
{{Warning|console 未定义}} | {{Warning|console 未定义}} | ||
| 第46行: | 第69行: | ||
== 全局参数 == | == 全局参数 == | ||
=== app === | === app === | ||
===== | [[/打印app参数|打印app参数]] | ||
=== CSInterface === | |||
==== cs.evalScript ==== | |||
==== app.documents[] ==== | ==== app.documents[] ==== | ||
<pre> | <pre> | ||
backgroundLayer | backgroundLayer: undefined | ||
bitsPerChannel | bitsPerChannel: {} | ||
colorProfileType | colorProfileType: {} | ||
colorProfileName | colorProfileName: "sRGB IEC61966-2.1" | ||
mode | mode: {} | ||
componentChannels | componentChannels: undefined | ||
activeHistoryState | activeHistoryState: undefined | ||
activeHistoryBrushSource | activeHistoryBrushSource: undefined | ||
activeLayer | activeLayer: undefined | ||
activeChannels | activeChannels: undefined | ||
info | info: undefined | ||
printSettings | printSettings: undefined | ||
fullName | fullName: {} | ||
height | height: {} | ||
managed | managed: undefined | ||
saved | saved: false | ||
name | name: "奇舞团1024.psd" | ||
path | path: {} | ||
quickMaskMode | quickMaskMode: false | ||
resolution | resolution: 72 | ||
selection | selection: undefined | ||
width | width: {} | ||
histogram | histogram: [71535,7293,5468,3646,6469,5214,12183,11680,5003,12525,5398,6748,5388,14143,8384,11624,24381,3429,3230,3114,5720,3640,1221,1629,22467,1158,1153,3571,1436,1623,2773,2077,3484,4585,5683,3904,4154,8292,8442,5839,9008,8966,8784,7912,4083,6197,9375,5235,3243,3502,6795,2597,2191,2476,7599,2162,1984,10587,1354,1593,2474,2097,3794,3398,3559,5777,8850,10196,11919,4187,4749,4922,3912,8149,13649,11313,12215,2526,5300,3627,4856,5406,21288,7746,16727,8153,7885,5069,4892,3826,6051,5245,6941,3454,4765,3015,3973,2262,2001,1680,1866,2102,4390,5216,9510,7924,19941,6510,13280,7135,6444,7524,12219,1076,1169,1106,1181,1184,1172,1738,1086,811,1025,951,637,674,1109,1526,899,944,810,361,1083,1045,949,1384,1146,1112,1687,1045,2216,475,1930,2515,2234,1618,1340,1292,1648,1405,694,2292,1924,702,770,1019,541,1158,601,1447,882,672,717,936,1039,817,702,334,465,533,605,1288,879,1028,1608,435,468,254,9763,384,461,720,302,441,427,486,363,917,606,593,537,926,878,1105,1114,1120,5314,1139,502,1556,1908,634,1297,1358,1917,1766,3203,646,6812,1964,1012,2690,2112,2413,6310,430,2030,3254,1939,2577,1321,2484,2624,1399,1630,5981,6205,633,612,271,416,380,272,413,1976,561,1084,218,583,467,296,292,180,358,210,6174,300,407,307,196,318,142,690,1344,492,31687] | ||
pixelAspectRatio | pixelAspectRatio: 1 | ||
xmpMetadata | xmpMetadata: undefined | ||
measurementScale | measurementScale: undefined | ||
id | id: 255 | ||
layers | layers: undefined | ||
layerSets | layerSets: undefined | ||
artLayers | artLayers: undefined | ||
channels | channels: undefined | ||
guides | guides: undefined | ||
historyStates | historyStates: undefined | ||
layerComps | layerComps: undefined | ||
pathItems | pathItems: undefined | ||
countItems | countItems: undefined | ||
colorSamplers | colorSamplers: undefined | ||
cloudDocument | cloudDocument: false | ||
cloudWorkAreaDirectory | cloudWorkAreaDirectory: undefined | ||
typename | typename: "Document" | ||
parent | parent: undefined | ||
parseAppDocument: [{}] | |||
</pre> | </pre> | ||
参考: | |||
* https://theiviaxx.github.io/photoshop-docs/Photoshop/Document.html | |||
== 导出格式 == | |||
[[/导出格式|导出格式]] | |||
== photoshop dom == | == photoshop dom == | ||
=== 图层(ArtLayers) === | === 图层集合 === | ||
=== 图层组(LayerSets) === | ==== 图层(ArtLayers) ==== | ||
文档根目录的图层的集合。 | |||
<syntaxhighlight lang="javascript"> | |||
for (var i =0; i< app.activeDocument.artLayers.length; i += 1) { | |||
$.writeln("图层: " + app.activeDocument.artLayers[i].name); | |||
}</syntaxhighlight> | |||
==== 图层组(LayerSets) ==== | |||
图层组的合集 | |||
==== 图层和图层组(layers) ==== | |||
所有图层和图层组的集合 | |||
=== 遍历图层 === | |||
<syntaxhighlight lang="javascript"> | |||
function getLayers(layers, count) { | |||
var out = ''; | |||
for (var i =0; i<layers.length; i++) { | |||
if(layers[i].typename == 'LayerSet') { | |||
out += '\n ' + new Array(count + 1).join(' ') + '[' + layers[i].name + ']'; | |||
out += getLayers(layers[i].layers, count + 1); | |||
} else { | |||
out += '\n ' + new Array(count + 1).join(' ') + layers[i].name; | |||
} | |||
} | |||
return out; | |||
} | |||
$.writeln(getLayers(app.activeDocument.layers, 0));</syntaxhighlight> | |||
== 事件 == | |||
=== 属性 === | |||
{| class="wikitable" | |||
|- | |||
! 属性 !! 名称 !! 作用 | |||
|- | |||
| type || 类型 || 识别事件的名称 | |||
|- | |||
| scope || 作用范围 || "APPLICATION" (当前宿主应用)或者 "GLOBAL" (全局 | |||
|- | |||
| appId || 应用 ID || 生成事件的宿主应用的识别名称。可选 | |||
|- | |||
| extensionId || 扩展 ID || 生成事件的扩展的识别名称。可选 | |||
|- | |||
| data || 数据 || 事件携带的数据 | |||
|} | |||
=== 事件分类 === | |||
==== CEP 事件 ==== | |||
===== 事件类型 ===== | |||
* 宿主程序事件(applicationActivate、documentAfterActivate 等)。 | |||
** documentAfterActivate 文档被激活 | |||
:: <syntaxhighlight lang="html5"> | |||
<documentAfterActivate><name>biaozhu-第十二版-多画板</name><url>file:///C:/Users/365/Pictures-第十二版-多画板.psd</url></documentAfterActivate></syntaxhighlight> | |||
* 自定义事件。 | |||
宿主事件列表 | |||
{| class="wikitable" | |||
|- | |||
| com.adobe.csxs.events.AppOffline || applicationActivate || documentAfterActivate | |||
|- | |||
| com.adobe.csxs.events.AppOnline || applicationBeforeQuit || documentAfterDeactivate | |||
|- | |||
| documentEdited || 示例 || 示例 | |||
|} | |||
==== ExtendScript 事件 ==== | |||
com.adobe.PhotoshopJSONCallback 事件集中监听 ExtendScript 事件,并自己通过 eventID 判断接受到的是何种事件 | |||
==== 参考 ==== | |||
[[/photoshop_Events_CC2015_ver_16|Photoshop Events (CC2015 ver.16)]] | |||
=== 返回值 === | |||
选中图层事件: | |||
<syntaxhighlight lang="javascript"> | |||
{"_obj":"select","layerID":[136],"makeVisible":false,"null":{"_name":"多字体和颜色","_ref":"layer"}}</syntaxhighlight> | |||
切换 PSD 文档事件(根据 documentID): | |||
<syntaxhighlight lang="javascript"> | |||
{"documentID":416,"null":{"_offset":-1,"_ref":"document"}}</syntaxhighlight> | |||
== ID == | == ID == | ||
<pre> | <pre> | ||
| 第140行: | 第215行: | ||
| [[/charIDToTypeID|charIDToTypeID]] || 示例 || 示例 | | [[/charIDToTypeID|charIDToTypeID]] || 示例 || 示例 | ||
|} | |} | ||
=== eventID === | |||
{{Warning|<code>com.adobe.PhotoshopCallback</code>{{Version|photoshop cc 2015}} 被弃用。并启用 <code>com.adobe.PhotoshopJSONCallback</code>,同时必须将ExtensionID作为后缀添加。}} | |||
== debug == | == debug == | ||
* <nowiki>chrome://inspect/#devices</nowiki> chrome 端口调试 | |||
== 错误捕获 == | == 错误捕获 == | ||
| 第153行: | 第231行: | ||
== 开发记录 == | == 开发记录 == | ||
* [[/开发记录|开发记录]] | * [[/开发记录|开发记录]] | ||
== 提速 == | |||
<syntaxhighlight lang="javascript"> | |||
var r = new ActionReference(); | |||
var d = new ActionDescriptor(); | |||
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerID")); | |||
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum")); | |||
d.putReference(charIDToTypeID('null'), r); | |||
// 限制getd获取的范围提升代码响应速度,使用 r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerID")); | |||
var options = executeAction(charIDToTypeID( "getd" ), d, DialogModes.NO); | |||
var layerID= options.getInteger(stringIDToTypeID("layerID")); | |||
$.writeln (layerID)</syntaxhighlight> | |||
== 签名 == | |||
=== 开发者模式 === | |||
绕过签名,调试未签名的扩展。 | |||
* windows: 注册表 PlayerDebugMode 1,类型为 string。eq:<code>regedit > HKEY_CURRENT_USER/Software/Adobe/CSXS.8</code>。 | |||
* mac: 命令行输入 <syntaxhighlight lang="bash" inline> | |||
defaults write com.adobe.CSXS.8 PlayerDebugMode 1</syntaxhighlight>,配置所在位置,<code>/Users/ <username>/Library/Preferences/com.adobe.CSXS.8.plist</code>。需要重启 cfprefsd 进程。 | |||
=== 证书 === | |||
==== 自签名证书(self-signed certificates) ==== | |||
==== 商业签名证书(commercial certificates) ==== | |||
=== ZXPSignCmd === | |||
Adobe 官方发布的签名与打包的命令行工具。 | |||
* 创建证书 | |||
<blockquote><pre> | |||
ZXPSignCmd -selfSignedCert <countryCode> <stateOrProvince> <organization> <commonName> <password> <outputPath.p12> | |||
ZXPSignCmd -selfSignedCert <国家代码> <地区> <组织名> <证书所有者名称> <证书密码> <证书名.p12> | |||
</pre></blockquote> | |||
{{Shc_out|<syntaxhighlight lang="shell"> | |||
.\ZXPSignCmd.exe -selfSignedCert CN Beijing design.qihoo.net qihoo kangjian design-qihoo.p12</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
Signed successfully | |||
</syntaxhighlight>|PS|C:\work\ZXPSignCMD }} | |||
* 签名并打包 | |||
<blockquote><pre> | |||
ZXPSignCmd -sign <inputDirectory> <outputZxp> <p12> <p12Password> -tsa <timestampURL> | |||
ZXPSignCmd -sign <要打包的项目目录> <输出文件路径> <证书路径> <证书密码> -tsa <时间戳服务地址> | |||
</pre></blockquote> | |||
{{Shc_out|<syntaxhighlight lang="shell"> | |||
.\ZXPSignCmd.exe -sign ".\zip\net.qihoo.design\" ".\zip\net.qihoo.design.zip" ".\design-qihoo.p12" "kangjian"</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
Signed successfully | |||
</syntaxhighlight>|PS|C:\work\ZXPSignCMD }} | |||
== 用户数据或者下载内容 == | |||
== 二进制 == | |||
window.cep.fs? | |||
=== 文件路径 === | |||
Unix 风格的 <code>/</code> 分隔,Windows 风格的 <code>\\</code>。 | |||
==== 跨平台路径处理 ==== | |||
路径标准化 <code>path.normalize()</code> | |||
常用路径 | |||
{| class="wikitable" | |||
|- | |||
| process.execPath || 示例 || 示例 | |||
|- | |||
| __dirname || 示例 || 示例 | |||
|- | |||
| __filename || 示例 || 示例 | |||
|- | |||
| cs.getSystemPath(SystemPath.USER_DATA) || 示例 || 示例 | |||
|- | |||
| cs.getSystemPath(SystemPath.COMMON_FILES || 示例 || 示例 | |||
|- | |||
| cs.getSystemPath(SystemPath.MY_DOCUMENTS) || 示例 || 示例 | |||
|- | |||
| cs.getSystemPath(SystemPath.HOST_APPLICATION) || 示例 || 示例 | |||
|} | |||
=== Base64 === | |||
cep.encoding.convertion | |||
* .b64_to_ascii(base64str) Base64 字符串 以 ascii 编码转换为字符串 | |||
* .b64_to_utf8(base64str) Base64 字符串 以 UTF-8 编码转换为字符串 | |||
* .b64_to_binary(base64str) Base64 字符串以二进制编码转换为字符串 | |||
* .ascii_to_b64(ascii) | |||
* .utf8_to_b64(str) | |||
* .binary_to_b64(binary) | |||
文件写入二进制数据,必须得使用 Base64 模式??? | |||
window.cep.fs.writeFile ("D:/B.ico", inf.data, "Base64"); | |||
== 开题 == | == 开题 == | ||
* [[/Photoshop插件开发版本差异|Photoshop插件开发版本差异]] | * [[/Photoshop插件开发版本差异|Photoshop插件开发版本差异]] | ||
| 第170行: | 第336行: | ||
* https://www.ps-scripts.com/ | * https://www.ps-scripts.com/ | ||
* https://www.kirupa.com/motiongraphics/ps_scripting.htm | * https://www.kirupa.com/motiongraphics/ps_scripting.htm | ||
* http://objjob.phrogz.net/ | |||
* http://jongware.mit.edu/ | |||
== adobe 参考规范文件 == | == adobe 参考规范文件 == | ||
查看被注释掉的文本链接。 | |||
<!-- | |||
* [[File:photoshop_cc_2014_applescript_ref.pdf]] | * [[File:photoshop_cc_2014_applescript_ref.pdf]] | ||
* [[File:photoshop_cc_2014_applescript_ref_2.pdf]] | * [[File:photoshop_cc_2014_applescript_ref_2.pdf]] | ||
| 第212行: | 第383行: | ||
* [[File:Photoshop-CS6-Scripting-Guide.pdf]] | * [[File:Photoshop-CS6-Scripting-Guide.pdf]] | ||
* [[File:Photoshop-CS6-VBScript-Ref.pdf]] | * [[File:Photoshop-CS6-VBScript-Ref.pdf]] | ||
签名: | |||
* | |||
[[文件:SigningTechNote CC.pdf]] | |||
--> | |||