9 Replies
      Latest reply on Dec 16, 2019 1:42 PM by hhas01
      Raimund0815 Level 1 Level 1 (0 points)

        AppleScript 2.7, ScriptEditor 2.11, OS Catalina 10.15 (latest Udqate)

         

        After updating to Catalina I can't run some AppleScripts. Firstly I thought about a bug in my code, therefore I tried some AppleScripts published on the Apple developer site and got the same error bevahiour. Can anybody explain why this happens and how to solve this?

         

        Here the source of the scripts I tried without success:

         

        https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/ManipulateImages.html

         

        Listing 38-1AppleScript: Opening an image with Image Events

        1. -- Prompt for an image
        2. set theImageFile to choose file of type "public.image" with prompt ""
        3. -- Launch Image Events and open the image
        4. tell application "Image Events"
        5.   launch
        6.   open theImageFile
        7. end tell
        8. --> Result: image "My Image.png" of application "Image Events"

         

        error Output:

        tell application "Script Editor"

          choose file of type "public.image" with prompt ""

          --> alias "Intenso 4TB:Test:Work:Result:GOPR5491.jpg"

        end tell

        tell application "Image Events"

          launch

          open alias "Intenso 4TB:Test:Work:Result:GOPR5491.jpg"

          --> missing value

        end tell

        Ergebnis:

        missing value

         

         

        Listing 38-5AppleScript: Scaling an image

         

        1. -- Prompt for an image
        2. set theImageFile to choose file of type "public.image" with prompt ""
        3. -- Locate an output folder
        4. set theOutputFolder to (path to desktop folder as string)
        5. -- To scale by percentage, set this value to true. To scale to a specific size, set it to false.
        6. set scaleByPercentage to true
        7. -- Launch Image Events
        8. tell application "Image Events"
        9.   launch
        10.   -- Open the image
        11.   set theImage to open theImageFile
        12.   tell theImage
        13.   -- Determine a save name for the image
        14.   set theName to name
        15.   set theSaveName to "temp-" & theName
        16.   -- Scale the image by 50%
        17.   if scaleByPercentage = true then
        18.   scale by factor 0.5
        19.   -- Scale the image to 100px on its longese side
        20.   else
        21.   scale to size 100
        22.   end if
        23.   -- Save the image to the output folder, using the save name
        24.   save as file type in (theOutputFolder & theSaveName)
        25.   -- Close the image
        26.   close
        27.   end tell
        28. end tell

         

        Result on Catalina 10.15:

         

        error "„name of missing value“ can not read." number -1728 from name of missing value

         

        Here's the script output:

        tell application "Script Editor"

          choose file of type "public.image" with prompt ""

          --> alias "Intenso 4TB:Test:Work:Result:GOPR5491.jpg"

        end tell

        tell current application

          path to desktop as string

          --> "Macintosh HD:Users:raimund:Desktop:"

        end tell

        tell application "Image Events"

          launch

          open alias "Intenso 4TB:Test:Work:Result:GOPR5491.jpg"

          --> missing value

        Ergebnis:

        error "„name of missing value“ kann nicht gelesen werden." number -1728 from name of missing value

        • Re: AppleScript problem with Catalina?
          g3scb Level 1 Level 1 (0 points)

          Same problem exprienced with Catalina update 10.15.1 (19B88): Image Events results in 'missing value'.

            • Re: AppleScript problem with Catalina?
              Raimund0815 Level 1 Level 1 (0 points)

              It's still the same problem in any case you try to open an image in the image events object. Unfortunately I can not find any details about the cause of this fails, more important would be, if it is a known bug with Catlaina 10.15.x and if there is any info available to avoid these kind of problems. It is very uncool for all script autors who intend to use image envent objects for their tasks.

               

              So I will stop immediately any scripting activity until I know, why these problems happens and if they will be fixed asap.

               

              It is very uncool for developpers if they are surprised like like this! Developpers will expect running tools after updates of OSx released! The ios 13.2 extensions for xcode were alos released days after release of 10.15.1! No warning before updating was shown!
              Properly working tool chains are more important than emojis or super sound and graphics for play kids. Developpers are forced to use a perfect dev. Environment!

               

              I Hopefully look forward to any official feedback by apple. Current experience ist, that none of the initiated tickets regarding mentioned problems are responded satisfactoril.
              if these kind of problems will be future standard, it is more efficient to switch to MS tool chain and environment.

            • Re: AppleScript problem with Catalina?
              ostoura Level 1 Level 1 (0 points)

              Same here, all image events commands are not working anymore since catalina, i'll file a bug and i appreciate if everyone also do so

              • Re: AppleScript problem with Catalina?
                darjeelingsteve Level 1 Level 1 (0 points)

                These problems appear to be caused by Image Events not having Full Disk Access permissions. Fortunately it's an easy fix.

                 

                First, launch System Preferences and navigate to the Security and Privacy pane. Click the Privacy tab, scroll down the menu on the left, and click on Full Disk Access. Click the + icon in the right hand box, and navigate to System > Library > Core Services. Select Image Events, and click the Open button.

                 

                I wrote a full write-up of this here: https://darjeelingsteve.com/articles/Fixing-%22Image-Events%22-AppleScripts-Broken-in-macOS-10.15-Catalina.html . Hopefully that solves your problem.

                  • Re: AppleScript problem with Catalina?
                    sstanley Level 2 Level 2 (40 points)

                    As well as the permissions problem, Image Events doesn't seem to like being pass aliases. Convert them to file references («class furl») and it should work fine.

                    • Re: AppleScript problem with Catalina?
                      Raimund0815 Level 1 Level 1 (0 points)

                      Unfortunately this does not work in my case. I added the full disk access fpr image events, as well for the script editor too, as I tried your solution and still having the same problem.

                       

                      Are there any other access rights necessary? I sitll get the same results with the enabled full disk acces for Image Events: for e.g. "missing value"

                       

                      Which are the concrete preconditions for 10.15.2 to use Apple Scripts without any restrictions?

                      Thanks for your feedbacks if you can find any solution, which helps..

                        • Re: AppleScript problem with Catalina?
                          sstanley Level 2 Level 2 (40 points)

                          Did you try using a furl?

                           

                          Use this code:

                           

                          set theImageFile to choose file of type "public.image" with prompt ""

                          set theImageFile to theImageFile as «class furl»

                            • Re: AppleScript problem with Catalina?
                              hhas01 Level 1 Level 1 (20 points)

                              AppleScript bitrot setting in too? How delightful.

                               

                              At this point OP might want to consider switching to zsh scripting and go read the manpage for `sips`, which is the command line equivalent of Image Events.app minus [hopefully] its hassles. There are definitely faster, less painful ways to get through life than dealing with an obsolescent AppleScript stack and its creeping failures; nevermind filing bug reports that will never get actioned.

                               

                              --

                               

                              [For those unaware: Apple scrapped its Mac Automation team back in 2016 after multiple new product failures. The whole Apple event/OSA/AppleScript stack looks to be in maintenance mode now, so unlikely to receive any further updates outside of plugging security holes. The future of automation most likely lies now in the cross-platform Siri and its [conversational] Shortcuts backend. The underpinnings for the latter are already lurking in 10.15 so I expect the full package will land in 10.16 sometime next year.]