This script will do what you want:
// pref pixels
app.preferences.rulerUnits = Units.PIXELS; // call the source document
var srcDoc = app.activeDocument; // get original width and height
var imageWidth = srcDoc.width.value;
var imageHeight = srcDoc.height.value; //set max size
var maxSize = 3000; // vegetables
var resizeRes = 72; if (Math.abs(imageWidth > imageHeight)) { if (imageWidth > maxSize) { scaleWithStyle(maxSize, true, "Wdth") } } else { if (imageHeight > maxSize) { scaleWithStyle(maxSize, true, "Hght") } } // function scale with style ()// ----------------------------------------------------------------------------
function scaleWithStyle(input, style, widthOrHeight){ // ======================================================= var id01 = charIDToTypeID( "ImgS" ); var desc = new ActionDescriptor(); var id02 = charIDToTypeID( widthOrHeight ); // "Wdth" or "Hght" var id03 = charIDToTypeID( "#Pxl" ); desc.putUnitDouble( id02, id03, input ); var id04 = stringIDToTypeID( "scaleStyles" ); //scale styles desc.putBoolean( id04, style ); //scale styles var id05 = charIDToTypeID( "CnsP" ); // constrain proportions desc.putBoolean( id05, true ); // constrain proportions var id06 = charIDToTypeID( "Intr" ); var id07 = charIDToTypeID( "Intp" ); var id08 = charIDToTypeID( "Bcbc" ); desc.putEnumerated( id06, id07, id08 ); executeAction( id01, desc, DialogModes.NO );}