This seems to get close, I wonder if you could test it?
#target photoshop;
app.bringToFront();
main();
function main(){
if(!documents.length) return;
try{
var doc = app.activeDocument;
app.displayDialogs = DialogModes.NO;
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
var res = doc.resolution;
var inch = res;
var cm = inch / 2.54;
var mm = cm /10;
var warpFactor = mm * 1.8;
//$.writeln("1.8mm = " + warpFactor + " pixels");
var bnds = doc.activeLayer.bounds;
var Height = bnds[3].value - bnds[1].value;
//$.writeln("Height = " + Height);
var warpValue = warpFactor/Height * 100;
//$.writeln("WarpValue = " + warpValue);
warpArcUpper(warpValue + (warpValue/1.75) );
/*
bnds = doc.activeLayer.bounds;
Height = bnds[3].value - bnds[1].value;
$.writeln("Height = " + Height);
*/
}catch(e){
}
finally{
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
};
};
function warpArcUpper(warpValue) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
desc.putEnumerated( charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcs6') );
var desc2 = new ActionDescriptor();
desc2.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Rlt'), 0.000000 );
desc2.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Rlt'), -0.000000 );
desc.putObject( charIDToTypeID('Ofst'), charIDToTypeID('Ofst'), desc2 );
desc.putUnitDouble( charIDToTypeID('Hght'), charIDToTypeID('#Prc'), 100 );
var desc3 = new ActionDescriptor();
desc3.putEnumerated( stringIDToTypeID('warpStyle'), stringIDToTypeID('warpStyle'), stringIDToTypeID('warpArcUpper') );
desc3.putDouble( stringIDToTypeID('warpValue'), warpValue );
desc3.putDouble( stringIDToTypeID('warpPerspective'), 0.000000 );
desc3.putDouble( stringIDToTypeID('warpPerspectiveOther'), 0.000000 );
desc3.putEnumerated( stringIDToTypeID('warpRotate'), charIDToTypeID('Ornt'), charIDToTypeID('Hrzn') );
desc3.putInteger( stringIDToTypeID('uOrder'), 4 );
desc3.putInteger( stringIDToTypeID('vOrder'), 2 );
desc.putObject( stringIDToTypeID('warp'), stringIDToTypeID('warp'), desc3 );
desc.putEnumerated( charIDToTypeID('Intr'), charIDToTypeID('Intp'), charIDToTypeID('Bcbc') );
executeAction( charIDToTypeID('Trnf'), desc, DialogModes.NO );
};
Edit: No it doesn't work, but it did for a few tests. So looking forward to the answer
... View more