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

how do I export a .jpg file with at least <70kb out of photoshop?

Community Beginner ,
Mar 23, 2015 Mar 23, 2015

Copy link to clipboard

Copied

how do I export a .jpg file with at least <70kb out of photoshop?

TOPICS
Actions and scripting

Views

327

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 Expert ,
Mar 24, 2015 Mar 24, 2015

Copy link to clipboard

Copied

The issue of exporting to size has come up repeatedly but as far as I can tell none of the regulars has considered it interesting enough to pursue on this Forum.

A Scriptable approach (export, check size, if necessary scale and/or export with different settings, check size, …) is evident.

It may not be "fast", though.

Votes

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
Enthusiast ,
Mar 24, 2015 Mar 24, 2015

Copy link to clipboard

Copied

Here is an example that will try to reach the given size in steps of 4 in quality.

var saveFile = File(Folder.desktop + "/test");

var fileSize = 70;

try{

tmpFile = File(saveFile+".jpg");

for(var z =100;z>5;z -=4){

SaveForWeb(tmpFile,z);

var chkFile = File(saveFile+".jpg");

//$.writeln(tmpFile + " qual = " + z + " Size = " +(chkFile.length/1024).toFixed(2) + "k" );

if((chkFile.length/1024).toFixed(2) < (fileSize +1)) break;

tmpFile.remove();

}

if(!tmpFile.exists)  SaveForWeb(tmpFile,5);

}catch(e){$.writeln(e + " - " + e.line);}

function SaveForWeb(saveFile,jpegQuality) {

var sfwOptions = new ExportOptionsSaveForWeb();

   sfwOptions.format = SaveDocumentType.JPEG;

   sfwOptions.includeProfile = false;

   sfwOptions.interlaced = 0;

   sfwOptions.optimized = true;

   sfwOptions.quality = Number(jpegQuality);

activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);

};

Votes

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
Advisor ,
Mar 24, 2015 Mar 24, 2015

Copy link to clipboard

Copied

LATEST

This response, barring any errors, is the correct answer. It would be far easier if there were an ExportOptionsSaveForWeb.maxSize option, but there isn't.

Votes

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