batch export to filesize

Enthusiast ,
Feb 07, 2021 Feb 07, 2021

Copy link to clipboard

Copied

image processor is rubbish

image processor pro needs a load of faff to get it working

you cant include photoshop 2021 export in an action

 

this is pathetic!

How can this now be worse than it was 10 years ago?

Any suggestions for an alternative way to do this?

TOPICS
Problem or error

Views

52

Likes

translate

Translate

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 Community Professional ,
Feb 07, 2021 Feb 07, 2021

Copy link to clipboard

Copied

I'm not sure if it is worse, however, it is no better in this aspect. 😐

 

There are some custom scripts to save a file to a targeted file size on disk. I don't believe that they are specifically designed for batching, so it remains to be seen how well they would perform when recorded into an action and used with Batch, Image Processor, Image Processor or Picture Processor scripts.

 

Further code could be added for a custom bulk process.

 

I'll have to dig up these scripts for you... to be continued!

Likes

translate

Translate

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 Community Professional ,
Feb 08, 2021 Feb 08, 2021

Copy link to clipboard

Copied

https://mindfulretouch.com/the-course/saving/saving-quality/

 

There is an error on line 28, however, I'm, not sure what the fix is:

 

jpegQuality = jpegQuality – dec;

 

Full code:

 

var doc = app.activeDocument;
var filename = doc.name;
var foldername = doc.path.name;
var filepath = doc.path;
var parentfilepath = doc.path.parent
var jpegQuality = 70; // desired quality
var maxfilesize = 512000; // max size in bytes
var dec = 5; // decreasing step
var minimumqual = 50; //minumum desired quality
savefolder = new Folder(filepath + '/BATCH/');
savefolder.create();
saveFile = new File(savefolder + '/' + filename.split('.').slice(0, -1).join('.') + ".jpg");
doc.flatten();
doc.pathItems.removeAll();
doc.channels.removeAll();

function savebatchweb(saveFile, jpegQuality) {
    var sfwOptions = new ExportOptionsSaveForWeb();
    sfwOptions.format = SaveDocumentType.JPEG;
    sfwOptions.includeProfile = true;
    sfwOptions.interlaced = 0;
    sfwOptions.optimized = true;
    sfwOptions.quality = jpegQuality;
    doc.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
}
savebatchweb(saveFile, jpegQuality);
while (saveFile.length > maxfilesize) {
    jpegQuality = jpegQuality – dec;
    saveFile = new File(saveFile);
    saveFile.remove();
    savebatchweb(saveFile, jpegQuality);
    if (jpegQuality <= minimumqual) {
        break
    }
}
doc.close(SaveOptions.DONOTSAVECHANGES); //closes file

 

Likes

translate

Translate

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 Community Professional ,
Feb 08, 2021 Feb 08, 2021

Copy link to clipboard

Copied

Likes

translate

Translate

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