On my slow 2 GHz PC Windows 10 Photoshop 23.1 Save as Copy a PNG scripted Action manager code save a 8000 px by 8000 px PNG lowest compression lager file size to my ssd in 5 seconds.


/* =======================================================================
// 2021 John J. McAssey (JJMack)
// ======================================================================= */
// This script is supplied as is. It is provided as freeware.
// The author accepts no liability for any problems arising from its use.
// enable double-clicking from Mac Finder or Windows Explorer
#target photoshop // this command only works in Photoshop CS2 and higher
// bring application forward for double-click events
app.bringToFront();
/////////////////////////////////////////////////////////////////////////
// SET-UP Global Variables //
/////////////////////////////////////////////////////////////////////////
var scriptPath = $.fileName.substr(0,$.fileName.lastIndexOf("/")+1);
var scriptName = $.fileName.substr($.fileName.lastIndexOf("/")+1,$.fileName.lastIndexOf("."));
scriptName = scriptName.substr(0,scriptName.lastIndexOf("."));
var scriptExt = $.fileName.substr($.fileName.lastIndexOf("."));
//alert(scriptPath + scriptName + scriptExt);
// Initialize variables used in mainline
var folderListCopy = new Array;
var fileListCopy = new Array;
var fileTypes = "";
var logData = "";
// Save the current preferences and Set Photoshop to use pixels and display no dialogs
var startRulerUnits = app.preferences.rulerUnits;
var startTypeUnits = app.preferences.typeUnits;
var startDisplayDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
try {
startDate = (getDateTime());
var fileName = app.activeDocument.name.replace(/\.[^\.]+$/, ''); // strip the extension off = app.activeDocument.name.replace(/\.[^\.]+$/, ''); // strip the extension off
var fileType = ".png"
var outputFile = new File(Folder.desktop + "/" + fileName + fileType );
SaveCopyAsPng(6, outputFile, true, true);
endDate = (getDateTime());
alert("Start " + startDate + "\n"
+ "End " + endDate + "\nTime "
+ elapseTime(startDate,endDate) + " hrs:min:sec"
);
}
catch(e) { alert(e + ': on line ' + e.line, 'Photoshop Error', true); }
// Return the app preferences
app.preferences.rulerUnits = startRulerUnits;
app.preferences.typeUnits = startTypeUnits;
app.displayDialogs = startDisplayDialogs;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
function SaveCopyAsPng(compression, In, copy, lowerCase) {
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
descriptor2.putEnumerated( stringIDToTypeID( "method" ), stringIDToTypeID( "PNGMethod" ), stringIDToTypeID( "quick" ));
descriptor2.putEnumerated( stringIDToTypeID( "PNGInterlaceType" ), stringIDToTypeID( "PNGInterlaceType" ), stringIDToTypeID( "PNGInterlaceAdam7" ));
descriptor2.putEnumerated( stringIDToTypeID( "PNGFilter" ), stringIDToTypeID( "PNGFilter" ), stringIDToTypeID( "PNGFilterAdaptive" ));
descriptor2.putInteger( stringIDToTypeID( "compression" ), compression );
descriptor.putObject( stringIDToTypeID( "as" ), stringIDToTypeID( "PNGFormat" ), descriptor2 );
descriptor.putPath( charIDToTypeID( "In " ), In );
descriptor.putInteger( stringIDToTypeID( "documentID" ), 1045 );
descriptor.putBoolean( stringIDToTypeID( "copy" ), copy );
descriptor.putBoolean( stringIDToTypeID( "lowerCase" ), lowerCase );
descriptor.putEnumerated( stringIDToTypeID( "saveStage" ), stringIDToTypeID( "saveStageType" ), stringIDToTypeID( "saveBegin" ));
executeAction( stringIDToTypeID( "save" ), descriptor, DialogModes.NO );
}
function getDateTime() { // Function for returning current date and time
var date = new Date();
var dateTime = "";
if ((date.getMonth() + 1) < 10) { dateTime += "0" + (date.getMonth() + 1) + "/"; }
else { dateTime += (date.getMonth() + 1) + "/";}
if (date.getDate() < 10) { dateTime += "0" + date.getDate() + "/"; }
else { dateTime += date.getDate() + "/"; }
dateTime += date.getFullYear() + " ";
if (date.getHours() < 10) {dateTime += "0" + date.getHours() + ":"; }
else { dateTime += date.getHours() + ":"; }
if (date.getMinutes() < 10) { dateTime += "0" + date.getMinutes() + ":"; }
else { dateTime += date.getMinutes() + ":"; }
if (date.getSeconds() < 10) { dateTime += "0" + date.getSeconds(); }
else { dateTime += date.getSeconds(); }
return dateTime;
}
function timeString () { // Function for returning raw time
var now = new Date();
return now.getTime()
};
function timeStamp(){
// Get the time and format it
var digital = new Date();
var hours = digital.getHours();
var minutes = digital.getMinutes();
var seconds = digital.getSeconds();
var amOrPm = "AM";
if (hours > 11) amOrPm = "PM";
if (hours > 12) hours = hours - 12;
if (hours == 0) hours = 12;
if (minutes <= 9) minutes = "0" + minutes;
if (seconds <= 9) seconds = "0" + seconds;
// Get the date and format it
var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
// create a variable with the fully formatted the time and date
// todaysDate = hours + ":" + minutes + ":" + seconds + " " + amOrPm + " - " + day + "/" + month + "/" + year;
// todaysDate = hours + ":" + minutes + ":" + seconds + " " + amOrPm + " - " + month + "/" + day + "/" + year;
MonthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
//todaysDate = hours + ":" + minutes + ":" + seconds + " " + amOrPm + " " + MonthNames[date.getMonth()] + " " + date.getDate() + ", " + year;
todaysDate =MonthNames[date.getMonth()] + " " + date.getDate() + ", " + year +" " + hours + ":" + minutes + ":" + seconds + " " + amOrPm;
return todaysDate;
}
function elapseTime(start,end) {
var date1 = new Date(start);
var date2 = new Date(end);
var diff = date2.getTime() - date1.getTime();
var msec = diff;
var hh = Math.floor(msec / 1000 / 60 / 60);
msec -= hh * 1000 * 60 * 60;
var mm = Math.floor(msec / 1000 / 60);
msec -= mm * 1000 * 60;
var ss = Math.floor(msec / 1000);
msec -= ss * 1000;
return (hh + ":" + mm + ":" + ss);
}