Right align image in QuarkXPress 6.5

Is there a way to use applescript to right align an image in it’s picture box?

I’m not on a computer with Quark right now, but check the AS dictionary for “image offset”, or “offset” (or something along those lines)

-N

I am working on more or less the same thing. It doesn’t seem possible to align right, but this has the same effect. The script fits the image to the box size, then fits the boxsize to the image and then aligns the bottom or the left to the original bounds.
Make a Quark doc with a picture box and a portrait image in it, select the box, then run the script.

kjeld

tell application "QuarkXPress Passport"
	activate
	tell current box of document 1
		try
			set bounds of image 1 to proportional fit
			
			set obnds to origin of bounds as list
			set boxtp to (coerce item 1 of obnds as point units to real)
			set boxlft to (coerce item 2 of obnds as point units to real)
			
			set bnds to bounds of image 1 as list
			set picscale to scale of image 1
			set picscale to coerce (picscale as percent point) to list
			set hscale to (coerce item 2 of picscale to real)
			set vscale to (coerce item 1 of picscale to real)
			
			set bot to (item 3 of bnds as point units as real) * vscale * 0.01
			set ri to (item 4 of bnds as point units as real) * hscale * 0.01
			set theOset to coerce (offset of image 1 as points point) to list
			set VO to (coerce item 1 of theOset to real)
			set HO to (coerce item 2 of theOset to real)
			set newtop to boxtp + (2 * VO)
			set newlft to boxlft + (2.01 * HO)
			
			set offset of image 1 to {0, 0}
			set newbot to newtop + bot
			set newri to newlft + ri
			set bounds to {newtop, newlft, newbot, newri} as points rectangle
			
		on error
			
		end try
		
	end tell
end tell

Im new to scripting and though I had this but maybe you can work out the errors of my ways. You want to set Yoffset to picture box width minus the width of the graphic. Heres how I tried but failed for now. I can’t get the last item from the actual bounds list. May be of some help…

tell application “QuarkXPress”
try
set thisBox to current box
if box type of thisBox is not picture box type or (file type of image 1 of current box) is null then error
on error
error “A single picture box containing an image must be selected.”
end try
set CurBox to object reference of current box
set boxW to ((width of bounds of current box) as millimeter units) as real
set boxH to ((height of bounds of current box) as millimeter units) as real
get actual bounds of (image 1 of CurBox)
copy (coerce ((actual bounds of image 1 of CurBox) as millimeter units) to list) to {“A”, “B”, “C”, “D”}
copy (coerce ((offset of image 1 of CurBox) as millimeter units) to list) to {Xoffset, Yoffset}
set Xoffset to Xoffset as real
set Yoffset to Yoffset as real
try
set (offset of image 1 of CurBox) to {(Xoffset), (boxW - D)}
end try
end tell

Had a thought and this is fairly simple centre the image get the Yoffset then double it. This one worked.

tell application “QuarkXPress”
set CurBox to object reference of current box
set bounds of image 1 of CurBox to centered
copy (coerce ((offset of image 1 of CurBox) as measurements point) to list) to {Xoffset, Yoffset}
set Xoffset to Xoffset as real
set Yoffset to Yoffset as real
try
set (offset of image 1 of CurBox) to {(Xoffset), (Yoffset * 2)}
end try
end tell

Sorry for mucking you about that last one set the Xoffset to the centered position this one keeps the original.

tell application “QuarkXPress”
set CurBox to object reference of current box
copy (coerce ((offset of image 1 of CurBox) as measurements point) to list) to {Xoffset, Yoffset}
set Xoffset to Xoffset as real
set bounds of image 1 of CurBox to centered
copy (coerce ((offset of image 1 of CurBox) as measurements point) to list) to {XXoffset, YYoffset}
set YYoffset to YYoffset as real
try
set (offset of image 1 of CurBox) to {(Xoffset), (YYoffset * 2)}
end try
end tell