0

いくつかのレイヤーを保存するスクリプトがあります。ただし、元のレイヤーサイズとして保存されます。

レイヤーを同じサイズで保存したい。

このようなスクリプトを知っているか、持っていますか?

4

1 に答える 1

0

ここに私がしばらく前に書いたいくつかのコードがあります:

var フォルダー = 新しいフォルダー (SOME_PATH); var ファイル = folder.getFiles();

for (var i = 0; i < files.length; i++)
{
app.load(files[i]);
var docRef = app.activeDocument;
resize(docRef);

var options = new ExportOptionsSaveForWeb();
var a = files[i].name.split('.');
var filename = a[0] + '.' + ( a[1].toLowerCase() != 'jpg' ? a[1] + '.' : '' ) + 'jpg';
var JPEGFile = new File( SOME_PATH + filename );

options.quality = 70;
options.format = SaveDocumentType.JPEG; //I Suppose you might want to save to some other format though
docRef.exportDocument(JPEGFile, ExportType.SAVEFORWEB, options);
docRef.close(SaveOptions.DONOTSAVECHANGES);

}

function resize(doc)
{
var TARGET = SOME_TARGET;   

var dist = Math.max(doc.width.as('px'), doc.height.as('px'));

if(dist > 0)
{
    var ratio = (TARGET / dist);
    var newWidth = new UnitValue(doc.width.as('px') * ratio, 'px')
    var newHeight = new UnitValue(doc.height.as('px') * ratio, 'px')
    doc.resizeImage(newWidth, newHeight);   
    //alert('width:' + doc.width * ratio + ' height:' + doc.height * ratio);
}

}
于 2010-06-26T08:55:10.953 に答える