3 Replies Latest reply on Sep 16, 2009 11:30 PM by Roy Marshall

    [JS][CS3] Pasting an image

    Roy Marshall Level 1

      Hi All

       

      I have no idea if this is possible, but i am trying to script a way to paste into an image frame a new picture from the clipboard (CMD+V) while retaining the scale and possition of the original. (I actually thought InDesign did this, but cannot find it).

       

      I have written the following to get the co-ordinates I need, but need help pasting the image.

       

      Once the image is in place, I can re-apply the co-ordinates.

       

      myFrame = app.selection[0];

      myImage = myFrame.graphics[0];

      myHorScale = myImage.horizontalScale;

      myVerScale = myImage.verticalScale;

      myGeo=myImage.geometricBounds;

       

      this is the bit that doesn't work....

      myUpdateImage = myImage.paste()

      or

      myImage.paste();

       

      or other variations.  I get the message 'paste is not a function'

       

      Any guidance would be cool as usual.

       

      Cheers

       

      Roy

        • 1. Re: [JS][CS3] Pasting an image
          Roy Marshall Level 1

          OK.  I have figured how to paste an image.  But, I am unable to get the properties of the image.  'myUpdateImage'

           

          myFrame = app.selection[0];

          myImage = myFrame.graphics[0];

          myHorScale = myImage.horizontalScale;

          myVerScale = myImage.verticalScale;

          myGeo=myImage.geometricBounds;

          myUpdateImage = app.paste();

          myPath = myUpdateImage.graphics[0].itemLink.filePath;

           

          I have figured that I can paste the item, get the file name, and populate the original frame with that new file, and delete the pasted frame......

           

          Still need help getting the file name for the pasted item.

           

          Cheers

           

          Roy

          • 2. Re: [JS][CS3] Pasting an image
            Roy Marshall Level 1

            OK!  I am there.  If any one has an alternative solution, please let me know.

             

            myFrame = app.selection[0];

            myImage = myFrame.graphics[0];

            myHorScale = myImage.horizontalScale;

            myVerScale = myImage.verticalScale;

            myGeo=myImage.geometricBounds;

             

            //New image Pasted

            myUpdateImage = app.paste();

             

            //getting all images on the page

            myDocFrames = myDoc.allPageItems;

             

            //finding the last image placed

            myNewFrame=myDocFrames[0]

             

            //getting path to new image

            myPath = myNewFrame.graphics[0].itemLink.filePath;

             

            //importing new image into selected frame

            myImage.place(myPath);

             

            //applying original settings

            myImage.horizontalScale= myHorScale;

            myImage.verticalScale=myVerScale;

            myImage.geometricBounds=myGeo;

             

            //getting rid of the temporary placed image

            myNewFrame.remove();

             

            Hopefully this can be usefull to others.

             

            Cheers

             

            Roy

            • 3. Re: [JS][CS3] Pasting an image
              Roy Marshall Level 1

              Hi

               

              Whereas the solution I have come up with is fine for most use, it is going to be used over a VPN connection, at best 20Mb/sec.  Pasting the clipboard image is fine, and if I can manipulate the pasted item, it would be good.

              My solution uses the pasted image to get the file path and name, and then uses this path to import over the top of the first image.  This action is slowing the process to a crawl.  Can I get a handle, and manipulate the pasted item, by pasting it into the old frame, removing the need to place the image by filename?

               

              If not, oh well, but would be good to.

               

              Cheers

               

              Roy