10 Replies Latest reply: Jun 9, 2010 6:22 AM by sam452sam452 RSS

    Indesign fitting image after placing

    sam452sam452

      I've gotten pretty far with using frame fitting options on image frames that are "loose" on a layout. But for image frames that are anchored in text is where I am failing, though Indesign does not present an error.

       

      I start with a document with some text. And I anchor a labeled image frame into a certain point in the text.

       

      I can place the image, but scaling and the frame fitting options just don't do anything that I can tell.

       

       

      set imgValue to "Assets:Signatures:AC_Vierra_sig1.tif"
      tell application "Adobe InDesign CS4"
           tell document 1
                set allRect to (every rectangle of every story whose label is "CS46Signature")
                if (count of allRect) > 0 then
                     repeat with thisRect in allRect
                          tell thisRect
                               set fitting alignment of frame fitting options to bottom left anchor
                               place imgValue 
                               redefine scaling to {1.0, 1.0}
                          end tell --ax
                     end repeat --drill down into img frames in text
                end if --allRect not empty
           end tell --theDoc
      end tell --app
      
      

       

      I've tried different combinations of these and they fail without error. What would you do given anchored image frames? thanx, sam

        • 1. Re: Indesign fitting image after placing
          sstanleyau Community Member

          Can you explain what you are actually trying to do to the image?

          • 2. Re: Indesign fitting image after placing
            sam452sam452 Community Member

            Yes, Shane.

             

            I want to bring the image in, anchor it in the bottom left corner, and force it to 100% scaling.

             

            Right now it comes in top left alignment and at 39 percent. I've not been able to figure out why Indesign scales images, but perhaps the dimensions of the image are larger than the box.

             

            But I end up having to manually align and scale it to 100 percent. I want the script to do the job.

             

            Thanks for looking at it, sam

            • 3. Re: Indesign fitting image after placing
              sstanleyau Community Member

              You're getting scaling because presumably that's how your anchored item options are set up in the document. Meanwhile your simplest approach is probably to place the image, fit given content to frame, set the transform reference point of the layout window to bottom left, then set horizontal and vertical scale to 100%.

              • 4. Re: Indesign fitting image after placing
                sam452sam452 Community Member

                Yes, but it doesn't seem to work. The document shows no changes. I've modified the above and attempted the following:

                 

                 

                set imgValue to "Assets:Signatures:AC_Vierra_sig1.tif"
                tell application "Adobe InDesign CS4"
                     tell document 1
                          -- set fitting on empty frame of frame fitting options to none --failed
                set allRect to (every rectangle of every story whose label is "CS46Signature")
                          if (count of allRect) > 0 then
                               repeat with thisRect in allRect
                                    tell thisRect
                                         
                set fitting on empty frame of frame fitting options to proportionally --also failed.
                
                set fitting alignment of frame fitting options to bottom left anchor --also failed
                
                                         
                place imgValue                           
                redefine scaling to {1.0, 1.0}                     
                end tell --ax                
                end repeat --drill down into img frames in text           
                end if --allRect not empty      
                end tell --theDoc 
                end tell --app 
                 
                
                

                 

                 

                It is curious if you go to the menu to do it manually and select Object/Fitting Options, you'll see that the alignment is shown to be as I wanted. Yet outside of that dialog, the document pallette and document have a disconnect between these two views. I would have thought that they are two views of the same function, but apparently I'm wrong. I wonder why there is a disconnect?

                 

                thanx, sam

                • 5. Re: Indesign fitting image after placing
                  sstanleyau Community Member

                  You're doing things the hard way. First, set the transform reference point outside your loop:

                   

                   

                     set transform reference point of layout window 1 to bottom left anchor

                   

                  Then inside your loop, just do this:

                  set {thePic} to place imgValue on thisRect

                  fit thePic given content to frame

                  set properties of thePic to {horizontal scale:100, vertical scale:100}

                  • 6. Re: Indesign fitting image after placing
                    sam452sam452 Community Member

                    Thank you for this direction. Apparently my disconnect is between the abstraction of layout window to the document. I'm unsure of the practicalities of how/when to deal with this distinction. It strikes me as odd that I don't have to do this when the image is "loose" in a layout. I'm only getting this trouble when I have an image frame in text.

                     

                    As it is, the revision fails on the setting of the scaling. The general form of the error is "Can’t set «class qpro» of {«class imag» id 2479 of «class crec» id 2467 of text from character 2872 to character 2872 of text flow id 210 of document 1 of application "Adobe InDesign CS4"} to {100, 100}."

                     

                    I've taken that command out of the loop, but it fails there, too. It appears it's balking at the fact that it is an image in text?

                     

                    What am I overlooking here? thanx, sam

                    • 7. Re: Indesign fitting image after placing
                      sstanleyau Community Member

                      Try changing:

                       

                      set properties of thePic to {horizontal scale:100, vertical scale:100}

                       

                      to:

                       

                      set properties of thePic to {absolute horizontal scale:100, absolute vertical scale:100}

                      • 8. Re: Indesign fitting image after placing
                        sam452sam452 Community Member

                        Thanks for sticking with me, Shane.

                         

                        It failed again, but I looked at your snippet again to see if I missed anything. The only difference that I thought was cosmetic was that you put thePic variable in {}. But apparently, it isn't cosmetic. When i placed braces around my variable it worked.

                         

                        I'm unaware of why that is?, sam

                        • 9. Re: Indesign fitting image after placing
                          sstanleyau Community Member

                          The place command returns a list (of one item). By using brackets, the variable contains the item from the list.

                          • 10. Re: Indesign fitting image after placing
                            sam452sam452 Community Member

                            I would not have gotten this far if you were not patient to the end, Shane. Based on your responses, the working snippet works for an empty image frame embedded in text.

                             

                            set imgValue to "myserver:Vierra_sig1.tif"
                            tell application "Adobe InDesign CS4"
                                 tell document 1
                                      set transform reference point of layout window 1 to bottom left anchor
                                      set allRect to (every rectangle of every story whose label is "CS46Signature_Code")
                                      if (count of allRect) > 0 then
                                           repeat with thisRect in allRect
                                                tell thisRect
                                                     set {ax} to place imgValue 
                                                     fit ax given content to frame
                                                     set properties of ax to {absolute horizontal scale:100, absolute vertical scale:100}
                                                end tell --ax
                                           end repeat --drill down into img frames in text
                                      end if --allRect not empty
                                      set transform reference point of layout window 1 to top left anchor
                                 end tell --doc1
                            end tell --app