2 Replies Latest reply on Oct 26, 2013 7:01 AM by bastieneichenberger

    encoding and app.doScript

    bastieneichenberger Level 1

      Hi all,


      I try to use the function app.doScript to run an applescript. This script use the terminal to look if an picture has an alpha channel.

      My function works with files who not contains special char.


      Has some one an idea to correct this bug?


      I become the following error:


      set result to do shell script "sips -g hasAlpha '/Users/bastieneichenberger/Desktop/indd_resize_script/2013-10-19_17-56-00__test.indd/Lin ks/Capture d’écran 2013-10-05 à 12.05.19.png'"

      Warning: /Users/bastieneichenberger/Desktop/indd_resize_script/2013-10-19_17-56-00__test.indd/Link s/Capture d’e<0301>cran 2013-10-05 a<0300> 12.05.19.png not a valid file - skipping

      Error 4: no file was specified

      Try 'sips --help' for help using this tool





      #target indesign
      var file_path = "/Users/bastieneichenberger/Desktop/indd_resize_script/2013-10-19_17-56-00__test.indd/Links/Capture d’écran 2013-10-05 à 12.05.19.png"
      alert(has_item_alpha_channel (file_path) );
      function has_item_alpha_channel (file_path){
          if(File.fs == "Windows"){
              throw new Error("the function has_alpha_channel works only on mac os x");
          var appleScript = "set result to do shell script \"sips -g hasAlpha '"+  file_path +"'\"";
          var result = app.doScript(appleScript, ScriptLanguage.applescriptLanguage);
          var res = result.match("hasAlpha: yes");
          if(res != null){
              res = true;
              res = false;
          return res;
        • 1. Re: encoding and app.doScript
          rob day Adobe Community Professional & MVP

          You should post in the scripting forum. It looks like you are making things too complicated. You shouldn't need a shell script to check for alpha channels—a list of alpha channels is stored in a placed image's clipping path property.


          This AppleScript displays the count of alpha channels in a selected image (you should be able to do the same in JS):


          --x returns a list of alpha channels—will return {} if there are none

          tell application "Adobe InDesign CS6"

              set x to alpha channel path names of clipping path of selection of active document

              set c to count of x

              display dialog "There are " & c & " alpha channels in the selected image"

          end tell

          • 2. Re: encoding and app.doScript
            bastieneichenberger Level 1



            Thanks you for your help! It's was very helpfull!