Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
1

Resized Images Created Via Photoshop Script Too Large File Size

New Here ,
Nov 09, 2020 Nov 09, 2020

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);
}

 

 

 

TOPICS
Actions and scripting , Windows

Views

788
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
People's Champ ,
Nov 09, 2020 Nov 09, 2020

Copy link to clipboard

Copied

Are you sure the problem is with resizeImage and not saveAs?

There are some errors in your script.

What is app.activeDocuments?

You are setting the wrong parameters for saving PNG.

pngOptions.quality = 5; What is this nonsense?

I'm not sure if Adobe fixed saving to PNG via the DOM savеAs() method.

Read about the problem here https://community.adobe.com/t5/photoshop/specifying-compression-in-pngsaveoptions-broken/m-p/1023233...
 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 24, 2020 Nov 24, 2020

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

LOL! Not even a little bit harsh 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2023 Dec 19, 2023

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)? 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

LATEST

Try doing the export with Image Processor Pro and see what results you get.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines