Apple-scripting "Place Image..." ?

Greg Titus greg at omnigroup.com
Mon Jul 14 16:14:00 PDT 2003


On Monday, July 14, 2003, at 03:42  PM, A. James Boswell wrote:

> Next question, (gee - give em an inch...). Is there an analogue to 
> this that will set an image to a URL from the web? (Sorry I'm at work 
> and can't test if "set image" works with a url or not).

Not directly within OmniGraffle, no. But the URL Access Scripting 
extension is included in OS X for just this purpose. So we modify the 
last script a bit and end up with the following:

set imageURL to "http://www.omnigroup.com/images/splash/titlebar.jpg"
set theFile to ((path to temporary items) as string) & "x.jpg"

tell application "URL Access Scripting"
	download imageURL to theFile replacing yes
end tell
tell application "Image Capture Scripting"
	set theImage to open (theFile as alias)
	set theSize to {width of theImage, height of theImage}
	close theImage
end tell
tell application "OmniGraffle Professional"
	tell page of front window
		make new shape at end of graphics with properties {origin:{0, 0}, 
size:theSize, draws stroke:false, draws shadow:false}
		set image of result to POSIX path of theFile
	end tell
end tell

Hope this helps,
	 - Greg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 4592 bytes
Desc: not available
Url : /mailman/archive/omnigraffle-users/attachments/20030714/f93fa58d/attachment.bin


More information about the OmniGraffle-Users mailing list