The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniGraffle > OmniGraffle General
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Placing several images at once (script) Thread Tools Search this Thread Display Modes
File > Place image ... in the OG menu appears to allow the placement of only one image at a time.

I had to place a number of images on several canvases today, and wrote a script to allow for selecting and placing several images at once, rather than having to do it one by one.

The fruit of this laziness and impatience is below. I was bringing images in as thumbnails, scaled to 20%. You can adjust the scaling by editing the prScale property at the top of the script.

Code:
property pTitle : "Place several images     Ver 0.6" -- IN OMNIGRAFFLE
property plngAcross : 4 -- number of thumbnails to place in a row
property prScale : 0.2 -- thumbnail size as a proportion of full size
property pblnShadow : false


--	Ver 0.6	Compatible with Launchbar's 'Instant Send' function
--				Select some files in the Finder, 
--				activate 'Send to' with a double-tap, 
--					Launchbar Preferences > Shortcuts > Modifier taps > Instant send
--				and select the script with its assigned abbreviation.


on run
	-- CHOOSE SOME IMAGES (SELECTING SEVERAL IMAGES FROM THE FILE DIALOG)
	tell application id "sevs"
		activate
		set lstFiles to (choose file with prompt "Place one or more images" with multiple selections allowed)
	end tell
	
	PlaceFiles(lstFiles)
end run

on open (lstFiles)
	PlaceFiles(lstFiles)
end open

on PlaceFiles(lstFiles)
	-- PLACE ALL THE SELECTED IMAGES IN A NEW DOCUMENT
	tell application id "OGfl"
		activate
		tell front canvas of (make new document with properties {automatic layout:false})
			set {rOriginX, rOriginY} to {0, 0}
			set lngMaxHeight to 0
			
			set i to 0
			set my text item delimiters to "/"
			repeat with oFile in lstFiles
				try
					-- GET THE DIMENSIONS OF THE IMAGE
					set strFile to POSIX path of oFile
					-- Image events
					tell application id "imev"
						tell (open file strFile)
							set {rX, rY} to dimensions
							close saving no
						end tell
					end tell
					
					-- SCALE DOWN TO THUMBNAIL
					set {lngWidth, lngHeight} to {rX * prScale, rY * prScale}
					
					-- AT THE END OF THE ROW RETURN TO LEFT HAND PAGE, AND MOVE DOWN A ROW
					if i ≥ plngAcross then
						set rOriginX to 0
						set rOriginY to rOriginY + lngMaxHeight
						set lngMaxHeight to 0
						set i to 0
					else
						-- RECORD THE MAXIMUM DEPTH IN THE CURRENT ROW OF THUMBNAILS
						if lngHeight > lngMaxHeight then set lngMaxHeight to lngHeight
					end if
					
					-- CREATE A THUMBNAIL with [folder/filename] of source image in url
					set strPathEnd to (items -2 thru -1 of (text items of strFile)) as string
					make new shape with properties {origin:{rOriginX, rOriginY}, size:{lngWidth, lngHeight}, draws stroke:false, fill:no fill, draws shadow:pblnShadow, image:strFile, url:strPathEnd}
					
					-- AND INCREMENT THE HORIZONTAL POSITION
					set rOriginX to rOriginX + lngWidth
					set i to i + 1
				on error
					display alert strFile & " does not appear to be a graphic file ..."
				end try
			end repeat
			set my text item delimiters to space
		end tell
	end tell
	
end PlaceFiles

Last edited by RobTrew; 2011-05-29 at 03:01 PM.. Reason: Ver 0.6 made it compatible with LaunchBar 'Instant Send' function
 
Ver 0.2 above tightens up the vertical spacing of the thumbnail grid.
 
And Ver 0.3 places the path of the source file in the URL field of the shape.

(i.e. each placed image is automatically assigned an 'opens URL' action - this is helping me to rapidly generate HTML image maps from the thumbnail grid).

--

Last edited by RobTrew; 2011-05-30 at 02:13 AM..
 
Ver 0.6 is now compatible with Launchbar's 'Instant Send' function
  1. Select some files in the Finder,
  2. activate LaunchBar's 'instant send' with a double tap [as specified under Launchbar Preferences > Shortcuts > Modifier taps > Instant Send]
  3. select this script with its assigned abbreviation.
  4. The linked thumbnails will appear in a fresh OmniGraffle canvas

PS if you are not using Launchbar, you can still save this script in application format, and use it as a droplet - dragging files and dropping them on its icon.

--

Last edited by RobTrew; 2011-05-30 at 01:26 AM.. Reason: PS re droplet
 
Is there a way to be able to place the images as "link to image file" using your script?
 
Quote:
Originally Posted by deniseburton View Post
Is there a way to be able to place the images as "link to image file" using your script?
Probably worth checking with the ninjas through Help > Send Feedback, but my impression is that assigning a file name to the image property always loads the image rather than linking to it ...

(Can't immediately see an alternative approach).
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
placing images: default to "link"? proton OmniGraffle General 2 2010-02-07 11:51 AM
Placing Projects in Folders within the App? HappyDude OmniFocus for iPhone 3 2009-10-23 08:59 AM
Apple-Script triggered exports of selection into separate images in OmniGraffle 5 Pro Scifer_2008 OmniGraffle General 0 2008-09-03 07:01 AM
Odd problems with Placing a Linked Image Andrew N OmniGraffle General 2 2008-07-30 02:42 PM
placing lines over graphics noahwallach OmniGraffle General 1 2008-03-30 07:29 PM


All times are GMT -8. The time now is 11:52 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.