如何使用Javascript在Photoshop插件中读取当前文档的宽度和高度?

问题描述 投票:0回答:1

在创建插件时,是否可以从Photoshop获取/检索宽度和高度值?

我有一个Javascript函数,它依赖于能够找到当前文档的比例,以便继续执行两个单独的函数之一。

所以最终我希望能够按照以下方式编写if / else语句:

如果宽度/高度<1.5,则为function1,否则为function2。

javascript photoshop photoshop-script
1个回答
0
投票

所以我找到了答案。

在您的jsx文件中,您可以使用:

app.activeDocument.width

要么

app.activeDocument.height

或者 - 如果您希望从js文件中检索这些值,您可以使用:

csInterface.evalScript('app.activeDocument.width.as("px")',function(result){
    alert(result)
});

要么

csInterface.evalScript('app.activeDocument.height.as("px")',function(result){
    alert(result)
});
© www.soinside.com 2019 - 2024. All rights reserved.