Copy link to clipboard
Copied
I made a script to resize an image to widths at 4000, 7500, 9000. When exported the 7500/9000 are way too large as file sizes.
Like-
Manually increase size to 9000 width is 12 MB
Through script its 214 MB.
I tried to clear artefacts/metadata but it didn't work. I even tried to do each file individually instead of in a single for-loop but nothing worked. Any help is appreciated.
Here's my current script-
//Set Adobe Photoshop to use pixels and display no dialogs
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
app.displayDialogs = DialogModes.NO;
// first close all open documents
while (app.documents.length){
app.activeDocuments.close();
}
//input folder
var inputFolder = Folder('~/Downloads/RawPix');
var fileList = inputFolder.getFiles();
//output folder where images go when finished processing
var outputFolder = Folder.selectDialog("Choose Output Folder");
var pngOptions = new PNGSaveOptions();
pngOptions.quality = 5;
//iterates through folder
for(var a = 0; a< fileList.length; a++){
//opens file
var docRef= open(fileList[a]);
app.activeDocument = docRef;
// deletes old file extension
var fileNameNoExtension = docRef.name;
fileNameNoExtension = fileNameNoExtension.split( "." );
fileNameNoExtension.length--
//Changes width to 4000 while maintaing aspect ratio
docRef.resizeImage(7500,undefined,undefined,ResampleMethod.PRESERVEDETAILS);
//appends file extension and image size
var newOne = "/" +fileNameNoExtension+ "75.png";
docRef.saveAs(new File (outputFolder+newOne+".png"),pngOptions);
//closes open document
docRef.close(SaveOptions.DONOTSAVECHANGES);
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Look, I'm just getting started. This is my first ever photoshop script and I'm flying solo so no need to be harsh.
I modified the enlargement script written in the official Adobe Photoshop Javascript handbook to enlarge multiple images instead of just one.
I thought it was resizeImage versus saveAs because the first image resized is never too large(memory-wise) while the others always are.
I searched online for help but couldn't find anything definitive on why my newly saved images were too large. If you could point me towards a better save option that would be great.
Copy link to clipboard
Copied
LOL! Not even a little bit harsh
Copy link to clipboard
Copied
Please provide one of the afflicted images.
Is there an inordinate amount of Ancestors Metadata present (File > File Infor > Raw Data)?
Copy link to clipboard
Copied
Try doing the export with Image Processor Pro and see what results you get.