Place Image Quark 6.5

Hi All,

Please see the code below, I want to place imgaes on the picture boxes. Please let me know how I will do it.


tell application "Finder"
   set theFolder to (choose folder) as string
   tell application "QuarkXPress"
      set myDoc to front document
      tell myDoc
         set thePage to count of pages
         repeat with i from 1 to thePage by 1
            tell page i
               set theText to count of text box
               repeat with j from theText to 1 by -1
                  tell text box j
                     set theCon to ""
                     copy contents of paragraph 1 to theCon
                     set theCon to theCon as string
                     set theImagePath to theFolder & theCon
                     display dialog theImagePath
                     set content to picture content
                     -----place image theImagePath
                     
                  end tell
               end repeat
            end tell
         end repeat
      end tell
   end tell
end tell 

I am explaining below hope you will understand.

I told my operator to create text box of the same size of image and insert the image name.

In my code I took image path and concatenates with image name, see the code below.

set theImagePath to theFolder & theCon

Then I am changing the mode to picture mode, by

set content to picture content

At this time the picture box is selected, here only I want to insert the code to place the image. If you know the code then please give me.

Regards,

Model: G5
Browser: Firefox 2.0.0.3
Operating System: Mac OS X (10.4)

Set image 1 of picture box (object reference here) to file (file path here)

Here a basic example

set TheImage to (choose file) as string
tell application "QuarkXPress"
	activate
	tell document 1
		make new picture box at beginning with properties {bounds:{10, 10, 100, 180}, color:"None"}
		set image 1 of picture box 1 to alias TheImage
	end tell
end tell

hope it helps

Hi,

Set image 1 of picture box (object reference here) to file (file path here)

Shall I do like this.

set image 1 of picture box 1 to file theImagePath

.

At presnt I am on leave and away from my MAC so I can’t check it.

 set image 1 of picture box 1 to alias TheImage

Shall I do like this.

set image 1 of picture box 1 to alias theImagePath

.

Thanks

With just a quick test this may work for you. I would choose to place new picture box behind each text box to retain the object layer stack. Then remove the text boxes later. As you can see this is fairly easy to do if you apply names to items as it runs through the loop. Hope it helps.

tell application "Finder"
	set theFolder to (choose folder) as text
end tell
tell application "QuarkXPress"
	activate
	set myDoc to front document
	tell myDoc
		set thePage to count of pages
		repeat with i from 1 to thePage
			tell page i
				set theText to count of text box
				repeat with j from theText to 1 by -1
					tell text box j
						set theCon to ""
						set x to get bounds
						set name to "DeleteMeLater"
						copy contents of (paragraph 1 as text) to theCon
						set theImagePath to theFolder & theCon as text
						-- display dialog theImagePath giving up after 2
					end tell
					make new picture box at after text box j with properties {name:theCon, bounds:x, color:"None"}
					set image 1 of picture box theCon to alias theImagePath
					set bounds of image 1 of picture box theCon to proportional fit
				end repeat
			end tell
		end repeat
		delete (every text box whose name is "DeleteMeLater")
	end tell
end tell

:o Hi Mark,

It is working very fine, but I want the box should be get resized as per Image size, that mean fit to image. Right now we are using

set bounds of image 1 of picture box theCon to proportional fit

How can I change it for fit to image.

Thanks
Rajeev

I haven’t tested this but I think it should do it.

tell application "Finder"
	set theFolder to (choose folder) as text
end tell
tell application "QuarkXPress"
	activate
	set myDoc to front document
	tell myDoc
		set thePage to count of pages
		repeat with i from 1 to thePage
			tell page i
				set theText to count of text box
				repeat with j from theText to 1 by -1
					tell text box j
						set theCon to ""
						set x to get bounds
						set name to "DeleteMeLater"
						copy contents of (paragraph 1 as text) to theCon
						set theImagePath to theFolder & theCon as text
						-- display dialog theImagePath giving up after 2
					end tell
					make new picture box at after text box j with properties {name:theCon, bounds:x, color:"None"}
					set image 1 of picture box theCon to alias theImagePath
					set width of bounds of picture box theCon to (width of actual bounds of image 1 of picture box theCon)
					set height of bounds of picture box theCon to (height of actual bounds of image 1 of picture box theCon)
				end repeat
			end tell
		end repeat
		delete (every text box whose name is "DeleteMeLater")
	end tell
end tell

edit added “picture box” before “theCon” as I used object reference.