【发布时间】: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