2016-10-11 7 views
0

私は画像を切り抜こうとしています。内からいくつかの画像を切り抜き画像

技術的には、文字、文字、数字です。

幅は504、高さは1008です。 各文字は24x24ピクセルのブロックだと思います。

私は自分自身をしばらく試してきましたが、私は切り抜きを理解できません。 私は、そのプロセス全体の原因を自動化することができない限り、得られていません。

これは今のところ私のスクリプトです。

hlineMinus = 0; 
//for (var i = 0; i < 21; i++) { 
    var doc = app.activeDocument; 
imageWidth = activeDocument.width.as('px'); 
imageHeight = activeDocument.height.as('px'); 
imageWidth - 24; 
imageHeight - 24; 

hline = i+1 * 24; 
hlineMinus = 0; 
if(hline = 21*24) 
hlineMinus += hline; 
hline=hlineMinus; 

    var bounds = [24*(i), 0, 24*(i+1), 24*(i+1)]; 
    doc.crop(bounds); 

    //do the math to figure out how big you want it after resize 
    //doc.resizeImage(newWidth, newHeight); 

    //note this is saving over the original!!!! 
     var opts, file; 
     opts = new ExportOptionsSaveForWeb(); 
     opts.format = SaveDocumentType.PNG; 
     opts.PNG8 = false; 
     opts.quality = 100; 
var d = i; 
     pngFile = new File(doc.path + d + doc.name); 
     app.activeDocument.exportDocument(pngFile, ExportType.SAVEFORWEB, opts); 
//app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 
//stepHistoryBack(); 

//} 

function stepHistoryBack(){ 
    var desc = new ActionDescriptor(); 
     var ref = new ActionReference(); 
     ref.putEnumerated(charIDToTypeID("HstS"), charIDToTypeID("Ordn"), charIDToTypeID("Prvs")); 
    desc.putReference(charIDToTypeID("null"), ref); 
executeAction(charIDToTypeID("slct"), desc, DialogModes.NO); 
}; 

答えて

0

boundsの固定された虚偽の値でスクリプトをテストしようとしましたか?構文が正しいように見えますが、数学は正しくありません。

関連する問題