2 Replies Latest reply on Aug 10, 2010 6:51 AM by Pieter van Helvoirt

    [JS] Apply alphachannel when placing image?




      I've got a tif image with several alpha channels. When placing the image manually I'm able

      to select which alpha channel InDesign should use as a clipping mask (via the import options dialog).


      According to the object model viewer the place method takes an object of properties as a

      parameter (withProperties parameter), but I'm only able to find the ImagePreference and

      ImageIOPreference properties of class Image - and they're both read-only(!)


      Can you help?

        • 1. Re: [JS] Apply alphachannel when placing image?
          r_olsen Level 1



          According to the scripting reference Image.place() method has signature:

          Image.place(fileName: File, showingOptions: bool, withProperties: obj)


          But same reference gives no clue on the construction of such an object.

          Apparently only the ImageIOPreference property of an image seems to

          hold any information about alpha channels, but it's read only..


          This won't work - inline object is ignored:

          var image = app.selection[0].images[0];
          var link = image.itemLink;
          // relink image and parse properties object:
          // ImageIOPreference.alphaChannelName
          image.place(link.filePath, false, {alphaChannelName:"Alpha 1"});
          // relink image and parse properties object:
          // ImageIOPreference.applyPhotoshopClippingPath
          image.place(link.filePath, false, {applyPhotoshopClippingPath:true});
          • 2. Re: [JS] Apply alphachannel when placing image?
            Pieter van Helvoirt

            Hi there,


            Here is how it works for me!



            // get reference to selected frame

            var myFrame = app.selection[0];

            // select the image to be placed

            var myImage = File.openDialog ("Select your image");

            // save current oldImageIOPreferences.applyPhotoshopClippingPath

            var oldAPCP = app.imageIOPreferences.applyPhotoshopClippingPath;

            // turn use of Photoshop clippingPath off

            app.imageIOPreferences.applyPhotoshopClippingPath = false;

            // place the image

            myImage = myFrame.place(myImage, false)[0];

            // turn use of alpha-channel on

            myImage.clippingPath.clippingType = ClippingPathType.ALPHA_CHANNEL;

            var myChannelNames = myImage.clippingPath.alphaChannelPathNames;

            //use the first channel

            if (myImage.clippingPath.alphaChannelPathNames.length > 0) {

            var myChannelName = myImage.clippingPath.alphaChannelPathNames[0];

            myImage.clippingPath.appliedPathName = myChannelName;


            // return to oldImageIOPreferences.applyPhotoshopClippingPath settings

            app.imageIOPreferences.applyPhotoshopClippingPath = oldAPCP;