9 Replies Latest reply: Feb 18, 2013 1:35 PM by Paul Riggott RSS

    CS6 png save options

    dgolberg Community Member

      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

        • 1. Re: CS6 png save options
          Muppet Mark Community Member

          Either put an if statement that checks the app version inside your function or test elsewhere and pass the value to your function… ( only got CS5 last year hum )

          • 2. Re: CS6 png save options
            dgolberg Community Member

            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.

            compression.jpg

            • 3. Re: CS6 png save options
              Paul Riggott Community Member

              Are you sure this is CS6 as I do not see these options, could it be someone is using a plugin?

              • 4. Re: CS6 png save options
                xbytor2 Community Member

                I see it in the the PSCS6 beta rev m.415 on Win7. No plugins in stalled. I don't have the scripting docs handy so I don't know if they added stuff in the DOM to support compression. He may have to end up using ActionManager code to get this to work.

                • 5. Re: CS6 png save options
                  eddit

                  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.

                  • 6. Re: CS6 png save options
                    misoa

                    Hi dgolberg

                    I had same problem and solved it.

                     

                    pngSaveOptions = new  PNGSaveOptions()

                    pngSaveOptions.compression=9  // (level of compression 0 .. 9       0 - without compression)

                    pngSaveOptions.interlaced=false


                    • 7. Re: CS6 png save options
                      dgolberg Community Member

                      That did it!  Thanks a ton misoa!

                       

                      Edit: And it also still works in CS4 without having to setup a version check to run it differently!

                      • 8. Re: CS6 png save options
                        Navarro Parker Community Member

                        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);

                         

                         

                        }

                        • 9. Re: CS6 png save options
                          Paul Riggott Community Member

                          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 );
                          };