in

Quark Forums

Centering image inside a picture box

Last post 07-02-2004 1:35 AM by phongleland. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 07-02-2004 1:35 AM In reply to

    Centering image inside a picture box

    Hi,

    I developed a script to create boxes and placing images inside of them, but I could not develop anything to center the image automatically. Can someone help me? Thanks
  • 07-02-2004 4:54 AM In reply to

    • JRS
    • Top 25 Contributor
    • Joined on 05-29-2004
    • Colorado
    • Posts 653

    Centering image inside a picture box

    You might need to just send a Command-Shift-M literal command to the application (may require an addition?) Centering is really just an action shortcut, not a persistent picture box property, so it may not be supported in the AppleScript interface. And you can't use do menu because it isn't on the menus either.
  • 07-02-2004 10:55 AM In reply to

    Centering image inside a picture box

    The thing is I can find the size of the image and the box, but setting the image offet only works for me if I do it immediately after I place the image. If I spend even one line of code to figure out the correct offset, it doesn't work. Really wierd. I'm using a 400 Mhz G4 with Quark 6 (not updated yet)
  • 07-02-2004 1:29 PM In reply to

    • pr9000
    • Top 50 Contributor
    • Joined on 06-07-2004
    • Minneapolis, MN
    • Posts 294

    Centering image inside a picture box

    show us your script and maybe it would make this simpler ...
  • 07-05-2004 6:43 AM In reply to

    Centering image inside a picture box

    Hi,

    I put the following in a function that is called from inside a loop

    tell application "QuarkXPress Passport"
    activate
    try
    set xposition to (init_width + ((coupon_width) * (column1 - 1)))
    set xend to (xposition + coupon_width)
    set yend to (yposition) + (coupon_height * heightfactor)
    tell page 1 of document 1
    make picture box at beginning with properties ¬
    {bounds:{yposition, xposition, yend, xend}, color:"None"}
    tell picture box 1
    set image 1 to alias (fileName)
    end tell
    end tell
    end try
    end tell

    i know the bounds of the picture box and after the picture is inserted, I know the dimensions of the picture. If I do

    tell picture box 1
    set image 1 to alias (fileName)
    set offset of image 1 to {30, 30}
    end tell

    it works

    but if I do

    tell picture box 1
    set image 1 to alias (fileName)
    set offsetx to (((width_of_box)-(width_of_picture))/2)
    set offsety to (((height_of_box)-(height_of_picture))/2)
    set offset of image 1 to {offsetx, offsety}
    end tell

    It doesn't work.

    Thanks.
  • 07-05-2004 7:22 AM In reply to

    Centering image inside a picture box

    I did the following and it works

    set bound1 to actual bounds of image 1 as list
    set image_width to item 4 of bound1 as real
    set image_height to item 3 of bound1 as real

    I didn't coerce the mm value to a real number

    cheers
  • 07-13-2004 10:16 PM In reply to

    • mphelps
    • Not Ranked
    • Joined on 07-09-2004
    • Ventura, CA
    • Posts 20

    Centering image inside a picture box

    Have you tried-
    "set bounds of image 1 to centered"

    Works when I use it.
    <M>
  • 07-14-2004 3:19 AM

    Centering image inside a picture box

    That much easier
Page 1 of 1 (8 items)
Powered by Community Server (Commercial Edition), by Telligent Systems