【问题标题】:Photoshop Script Image Resizing With If Else StatementPhotoshop 脚本使用 If Else 语句调整图像大小
【发布时间】:2014-06-25 10:33:38
【问题描述】:

如何使用 if else 语句来调整图像大小的 Photoshop 脚本。示例代码:

// get a reference to the current (active) document and store it in a variable named "doc"
doc = app.activeDocument;  

// change the color mode to RGB.  Important for resizing GIFs with indexed colors, to get better results
doc.changeMode(ChangeMode.RGB);  

// these are our values for the END RESULT width and height (in pixels) of our image
var fWidth = 500;
var fHeight = 500;

// do the resizing.  if height > width (portrait-mode) resize based on height.      otherwise, resize based on width
if (doc.width < "1000px") {
    doc.resizeImage(null,UnitValue(fWidth,"px"));
}
else {
    doc.resizeImage(UnitValue(fWidth,"px"),null,null,ResampleMethod.BICUBIC);
}

此代码将生成此代码。如果图像宽度低于 1000 像素,它将调整为 500 像素(高度自动基于原始图像大小)。我想调整宽度和高度的特定大小。

如果图像为 1000 像素 X 500 像素,此脚本会将图像调整为 500 像素 X 250 像素。我希望它是 500 像素 X 500 像素。我该怎么做?

【问题讨论】:

    标签: photoshop


    【解决方案1】:

    resizeImage 的文档显示参数是

    resizeImage([width][, height][, resolution][, resampleMethod])
    

    所以只需更改你的 resizeImage 调用来指定你想要的高度和宽度。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-23
      • 1970-01-01
      • 1970-01-01
      • 2012-05-02
      • 1970-01-01
      • 1970-01-01
      • 2012-07-17
      相关资源
      最近更新 更多