我是 Photoshop JSX 脚本的新手。到目前为止,我编写了一个小“hello world”脚本,它保存了第一个历史快照的 jpg 图像。
我想要知道活动图像中存在的历史快照的数量,但我找不到任何好的信息或示例。
您需要遍历并测试为每个Document.HistoryStates
调用的布尔值-如果状态是快照。snapshot
true
这是解决方案(感谢 c.pfaffenbichler):
xvar myDoc = app.activeDocument;
var theHist = myDoc.historyStates;
var theSnaps = new Array;
for (var m = 0; m < theHist.length; m++) {
var theState = theHist[m];
if (theState.snapshot == true) {theSnaps.push(theState)}
};
alert (theSnaps.length);
好的。不是吗?