SaveAs jpeg and lower quality to reach a max weight
hello,
i trying script loop lower jpgsaveoptions.quality until file weight reaches max weight jpg.
i tried this, doesn't seams work... maybe because jpg saved server , there timing issue.
thank loot help.
fred
var jpegquality = 8;
var kbmax = 50;
function savejpeg(savefile, jpegquality){
var doc = activedocument;
if (doc.bitsperchannel != bitsperchanneltype.eight) {
doc.bitsperchannel = bitsperchanneltype.eight;
};
jpgsaveoptions = new jpegsaveoptions();
jpgsaveoptions.embedcolorprofile = true;
jpgsaveoptions.formatoptions = formatoptions.standardbaseline;
jpgsaveoptions.matte = mattetype.none;
jpgsaveoptions.quality = jpegquality;
{
activedocument.saveas(savefile, jpgsaveoptions, true, extension.lowercase);
jpegquality--;
}
while (savefile.length > kbmax * 1000);
}
replace jpegquality--; with
jpgsaveoptions.quality--;
More discussions in Photoshop Scripting
adobe
Comments
Post a Comment