There are number of images.
The task is: resize every image to 2000px and it should be less than 500kb.
Current script (.jsx) resize images (app.activeDocument.resizeImage), but some of resized images bigger 500kb (save for web: for quality 81).
So the idea is to loop: check size of current image, if size>500, decrement quality to 80, check size and so on...
Some lines of code are:
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
...
var desc1 = new ActionDescriptor(); var desc2 = new ActionDescriptor();
...
desc2.putEnumerated(cTID('Fmt '), cTID('IRFm'), sTID("JPEGFormat"));
...
desc2.putInteger(cTID('Qlty'), 81);
...
desc2.putPath(cTID('In '), new File("/c/folder"));
desc1.putObject(cTID('Usng'), sTID("SaveForWeb"), desc2);
executeAction(cTID('Expr'), desc1, dialogMode);
- JavaScript in browser has no access to user's drive. So what about the jsx in Photoshop, looks like it's the same?
- Is it any way to check the size of the jpeg image what will be saved (with current quality) through cTID?