5 Replies Latest reply: May 21, 2013 7:17 AM by Mattmcquiff RSS

    Script that resizes canvas. But then won't save

    Mattmcquiff Community Member

               I have a script that will crop  some of transparent area  out, this is fine but when I want to physically crop into the actual image it won't automatically save. I think something needs suppressing (like clipping message),

       

      Its a long script, but keeping it to the one liner

       

      resize canvas height (LargeLandH) anchor position top center

       


        • 1. Re: Script that resizes canvas. But then won't save
          Mattmcquiff Community Member

          Here is a sample of the script and I get the same issue    and also the file I am working with

           

          https://dl.dropboxusercontent.com/u/82899493/screenShots/PU005PK_2.psd

           

           

           

          tell application "Adobe Photoshop CS6"

            activate

                    set myPNGOptions to {class:PNG save options, interlaced:false}

                    set aFolder to "StudioA:Users:StudioA:Desktop"

                    tell current document

                              tell application "Adobe Photoshop CS6"

                                        set ruler units of settings to pixel units

                              end tell

                              (delete layer "Original Image")

                              delete layer "BACKGROUND" of layer set "Dodge and Burn"

                              tell current layer to set name to "Main Image"

            merge visible layers

           

            trim basing trim on transparent pixels

           

            resize image width 960

            resize canvas height 700 anchor position top center

            save in (aFolder & name) as PNG with options myPNGOptions without copying

                    end tell

          end tell

          • 2. Re: Script that resizes canvas. But then won't save
            Muppet Mark Community Member

            Untested but from what I recall…

             

            tell application "Adobe Photoshop CS5"

              -- do your app stuff

                      set ruler units of settings to pixel units

                      set display dialogs to never

              activate

                      tell current document

              -- now do document stuff

                                (delete layer "Original Image")

                                delete layer "BACKGROUND" of layer set "Dodge and Burn"

                                tell current layer to set name to "Main Image"

              merge visible layers

              trim basing trim on transparent pixels

              resize image width 960

              resize canvas height 700 anchor position top center

                                -- use a flexible path to desktop

                                set aFolder to (path to desktop as text)

                                set myPNGOptions to {class:PNG save options, interlaced:false}

              save in (aFolder & name) as PNG with options myPNGOptions without copying

                      end tell

              -- do your app stuff

                      set ruler units of settings to mm units

                      set display dialogs to always

            end tell

            • 3. Re: Script that resizes canvas. But then won't save
              Mattmcquiff Community Member

              odd behaviour. How come when the image 'acually gets cropped' it throws up that error?

               

              Surely there must be away to crop without the error message.

               

              Still testing your script above and hopefully its a work around.

              • 4. Re: Script that resizes canvas. But then won't save
                Muppet Mark Community Member

                It's NOT a workaround but standard scripting procedure… I think everyone starts and ends PS scripts with this… Error dialogs are a different kettle of fish…

                • 5. Re: Script that resizes canvas. But then won't save
                  Mattmcquiff Community Member

                  No worries, all fully tested and working now!