ianPark
1/28/2020 - 10:18 PM

Resize Image To Pixel

// RESIZE IMAGE TO PIXELS (height or width, pixels)
function resizeImage(heightOrWidth, pixels) {
    if (heightOrWidth == "Height" || heightOrWidth == "height") { heightOrWidth = "Hght";}
    if (heightOrWidth == "Width" || heightOrWidth == "width") { heightOrWidth = "Wdth";}
    var desc001 = new ActionDescriptor();
    desc001.putUnitDouble( charIDToTypeID( heightOrWidth ), charIDToTypeID( "#Pxl" ), pixels );
    desc001.putUnitDouble( stringIDToTypeID( "resolution" ), stringIDToTypeID( "densityUnit" ), 72 );
    desc001.putBoolean( stringIDToTypeID( "scaleStyles" ), true );
    desc001.putBoolean( charIDToTypeID( "CnsP" ), true );
    var idautomaticInterpolation = stringIDToTypeID( "automaticInterpolation" );
    desc001.putEnumerated( charIDToTypeID( "Intr" ), charIDToTypeID( "Intp" ), idautomaticInterpolation );
    executeAction( charIDToTypeID( "ImgS" ), desc001, DialogModes.NO );
}