3 Replies Latest reply on Jul 31, 2013 1:20 PM by Greenlyt

    Saving a transparent PNG

    Greenlyt

      I have been trying to get my script to save off as a PNG. I am pretty sure that it is my options that are giving me the problems. Not sure if there are new terms for CS6 or if these are just wrong. Any help would be great.

       

      set newFileName to (outputFolder as string) & docBaseName & ("_" & docWidth & "x" & docHeight & ".png")

      export docRef in file newFileName as save for web with options {web format:PNG, transparency:true}

       

      Thanks.

        • 1. Re: Saving a transparent PNG
          c.pfaffenbichler Level 9

          Paul Riggott has posted some code that exports png-24

          http://forums.adobe.com/message/4271262#4271262

          1 person found this helpful
          • 2. Re: Saving a transparent PNG
            Greenlyt Level 1

            It seems to work but I am having troubles getting it to save where I need it to. I was using apple script to save them to a specific place as in the script I pasted in at first. Now with the addition it runs through the script correctly but I am not sure where or if the PNGs are being saved.

             

            Here is the section of the PNG script I am having troubles with in addition to the script that Paul used.

             

            if "px" is in pathItem then

                                            repeat with idx from 1 to (length of pathItem)

                                                if (item idx of pathItem = "x") then

                                                    set docWidth to (items 1 thru (idx - 1) of pathItem) as string

                                                    set docHeight to (items (idx + 1) thru ((length of pathItem) - 2) of pathItem) as string

                                                    exit repeat

                                                end if

                                            end repeat

                                            do javascript "Crop(); function Crop() {function cTID(s) { return app.charIDToTypeID(s); }; function sTID(s) { return app.stringIDToTypeID(s); }; var desc001 = new ActionDescriptor(); executeAction( cTID('Crop'), desc001, DialogModes.NO );};" show debugger on runtime error

                                            resize image docRef width (docWidth as integer) as pixels height (docHeight as integer) as pixels resolution 72

                                            (*

                                                tell application "Adobe Photoshop CS6"

                                                    flatten

                                                    filter current layer of the current document using unsharp mask with options ¬

                                                        {class:unsharp mask, amount:30, radius:1.2, threshold:3}

                                                end tell

                                            *)

                                            set newFileName to (outputFolder as string) & docBaseName & ("_" & docWidth & "x" & docHeight & ".png")

                                            do javascript "function sfwPNG24(saveFile,quality){

                                            var pngOpts = new ExportOptionsSaveForWeb;

                                            pngOpts.format = SaveDocumentType.PNG;

                                            pngOpts.PNG8 = false;

                                            pngOpts.transparency = true;

                                            pngOpts.interlaced = false;

                                            pngOpts.quality = quality;

                                            activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);}"

             

            I just need it to save off to the folder that the script had created. If you need the entire script let me know.

             

            This is the way it used to work:

             

            export docRef in file newFileName as save for web with options {web format:PNG, transparency:true}

             

            Thanks again.

            • 3. Re: Saving a transparent PNG
              Greenlyt Level 1

              I found a way to do what I needed in apple script. Here is what I did to get it to work in CS6.

               

              set PNGExportOptions to {class:save for web export options, quality:5, png eight:false, transparency:true, web format:PNG}

                      export thisDoc in filePath as save for web with options PNGExportOptions