4 Replies Latest reply on Jun 18, 2013 9:06 AM by Cooroo

    AS: Export error in CS6, worked in CS5

    Cooroo

      The following script snippet opens an image file, and saves out a thumbnail for use in a database.

       

      It works fine in Photoshop CS5 but in CS6 it errors on the 'export' command, with the message 'can't get current document'.

       

      Checking the CS6 dictionary I can't see anything wrong. I've tried 'document 1' etc but have the same problem. Any ideas? It's a crucial script that I use daily, but will soon lose access to CS5...

       

      tell application "Adobe Photoshop CS6"

      set myExportOptions to {quality:0}

       

                          set ruler units of settings to pixel units

       

        open file the_file

                          tell current document

                                    set image_height to the height as pixels

                                    set image_width to the width as pixels

                                    if image_height is greater than image_width then

        resize image height 300

        resize canvas width 300

                                    else

        resize image width 300

        resize canvas height 300

                                    end if

                                    set thumb to thumbs_path & the_filename & ".gif" as string

        export in file (thumb) as save for web with options myExportOptions

                                    close without saving

                          end tell

                end tell

        • 1. Re: AS: Export error in CS6, worked in CS5
          Muppet Mark Level 5

          You are missing a little code…? Where have you defined your variables thumbs_path & the_filename

           

          As is it don't work in CS5 for me… Sorry but NOT got CS6 to tinker with

          • 2. Re: AS: Export error in CS6, worked in CS5
            Cooroo Level 1

            Yes, it's just a snippet - the other parts of the script take place in FilemakerPro, so I didn't want to confuse the issue by including that.

             

            thumbs_path is just the path to a folder called 'Thumbnails' on our server, and the_filename is the number of the record in Filemaker.

             

            I'll post an adapted version that should work as a standalone. But I don't want to complicate the issue - the problem is really with the 'export' line. Everything else works.

             

            When you get a dialog, choose a single image file, and click cancel when it asks you for another:

             

            copy {} to doclist

            repeat

                      try

                                choose file with prompt "Choose an image file:"

                                copy doclist & (the result as string) to doclist

                      on error

                                exit repeat

                      end try

            end repeat

             

            tell me to open (doclist)

             

            on open image_list

             

                      set thumbs_path to path to desktop

                      repeat with the_image in image_list

                                tell application "Adobe Photoshop CS6"

                                          set myExportOptions to {quality:0}

             

                                          set ruler units of settings to pixel units

             

              open file the_image

                                          tell current document

                                                    set image_height to the height as pixels

                                                    set image_width to the width as pixels

                                                    if image_height is greater than image_width then

              resize image height 300

              resize canvas width 300

                                                    else

              resize image width 300

              resize canvas height 300

                                                    end if

                                                    set thumb to thumbs_path & "1.gif" as string

              export in file (thumb) as save for web with options myExportOptions

                                                    close without saving

                                          end tell

                                end tell

                      end repeat

            end open

            • 3. Re: AS: Export error in CS6, worked in CS5
              Muppet Mark Level 5

              I may be that it does not like your options…? Have you tried without those…?

               

              Quality is not one thats available for GIF I would use that when saving in JPEG.

               

              I would also tell it what format I wanted… {web format:CompuServe GIF}

              • 4. Re: AS: Export error in CS6, worked in CS5
                Cooroo Level 1

                Took out the option and it worked! TBH this was a script I'd lifted from elsewhere and adapted for my needs, and the line was probably never necessary.

                 

                Thanks so much!