JavaScript 适用于Adobe Photoshop CS2的图像缩放器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript 适用于Adobe Photoshop CS2的图像缩放器相关的知识,希望对你有一定的参考价值。

/*
resizer.jsx for Adobe Photoshop CS2

WARNING: this script changes documents that will be processed.
         so be sure to duplicate documents before script runs.

this script resizes images storing in given number of pixel.
smaller images than given number won't be resized.
all images will be changed into RGB color mode.

last update: 2006-10-26
*/

preferences.rulerUnits = Units.PIXELS;

cutVal = 960;
fileType = "*.psd";

folderObj = Folder.selectDialog("select folder");

if(folderObj != null) {
	inputFileType = prompt("input file type like '*.psd'", fileType);
	if(inputFileType != null) { fileType = inputFileType; }
	
	inputCutVal = prompt("input length (pixel)", cutVal);
	if(inputCutVal != null) { cutVal = eval(inputCutVal); }
	
	fileList = folderObj.getFiles(fileType);
	
	for(i = 0; i < fileList.length; i++) {
		open(fileList[i]);
		
		if(activeDocument.width.value > cutVal || activeDocument.height.value > cutVal) {
			if(activeDocument.width.value > activeDocument.height.value) {
				activeDocument.resizeImage(
					cutVal,
					(cutVal / activeDocument.width.value) * activeDocument.height.value,
					72,
					ResampleMethod.BICUBICSHARPER
					);
			} else {
				activeDocument.resizeImage(
					(cutVal / activeDocument.height.value) * activeDocument.width.value,
					cutVal,
					72,
					ResampleMethod.BICUBICSHARPER
					);
			}
		}
		
		activeDocument.changeMode(ChangeMode.RGB);
		
		activeDocument.close(SaveOptions.SAVECHANGES);
	}
}

以上是关于JavaScript 适用于Adobe Photoshop CS2的图像缩放器的主要内容,如果未能解决你的问题,请参考以下文章