2016-10-11 66 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的固定缺陷測試您的腳本?它看起來像語法是正確的,但數學不是。