I've got a major script I use that performs .png saving every few seconds, but apparently there are some new compression options in CS6. Is there a way for me to have the script use the "Smallest / Slow" compression option if CS6 is in use? I currently use the script below for saving:
function SavePNG(){
permSaveFile = new File(permSaveFile);
pngSaveOptions = new PNGSaveOptions();
activeDocument.saveAs(permSaveFile, pngSaveOptions, true, Extension.LOWERCASE);
}
How would I add the extra CS6 save option in while still being able to use the script with older versions as well? The rest of the script works fine and it saves fine under CS6; the only reason I need to change this is, the output files are HUGE using it, as is, under CS6. Thanks for any help!
dgolberg
That's kind of what I figured, but what do I have to change to get it to save using the "Smallest / Slow" compression if CS6 is detected? I'm not sure what changes need to be made to get it to change the compression type, as I don't currently have CS6 to test it with (and I probably wouldn't know what to change anyway, unless it's simply a second boolean in the "saveAs" line). There are people running this script, though, that are using CS6, so I need to make sure it's programmed in.
dgolberg is correct, this is a new option for cs6. I'm in the same boat, trying to find out how I can automate this option in.
I tried a quick hack to achieve this by running "Save As" manually and save it as an action, then call the action from your script HOWEVER I found that it doesnt seem to apply any compression at all, regardless of the fact that the action says it's using compression. I'm thinking there's a bug in here somewhere.
I'm doing something wrong. ![]()
I'm not getting any PNG compression in CS6 with this:
}
function SavePNG(saveFile){
pngSaveOptions = new PNGSaveOptions()
pngSaveOptions.compression=9 // (level of compression 0 .. 9 0 - without compression)
pngSaveOptions.interlaced=false
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}
You could try this...
var saveFile = File(Folder.desktop + "/test.png");
savePNGCS6(saveFile);
function savePNGCS6(saveFile) {
var desc = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putEnumerated( charIDToTypeID('PGIT'), charIDToTypeID('PGIT'), charIDToTypeID('PGIN') );
desc2.putEnumerated( charIDToTypeID('PNGf'), charIDToTypeID('PNGf'), charIDToTypeID('PGAd') );
desc2.putInteger( charIDToTypeID('Cmpr'), 9 );
desc.putObject( charIDToTypeID('As '), charIDToTypeID('PNGF'), desc2 );
desc.putPath( charIDToTypeID('In '), new File( saveFile ) );
desc.putInteger( charIDToTypeID('DocI'), 308 );
desc.putEnumerated( stringIDToTypeID('saveStage'), stringIDToTypeID('saveStageType'), stringIDToTypeID('saveSucceeded') );
executeAction( charIDToTypeID('save'), desc, DialogModes.NO );
};
North America
Europe, Middle East and Africa
Asia Pacific