Copy link to clipboard
Copied
how do I export a .jpg file with at least <70kb out of photoshop?
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.
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);
};
Copy link to clipboard
Copied
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.