Photoshop Bounds of a Selection

bounds (list, r/o) : bounding rectangle of the entire selection

Hello–

Anyone know how I can get the bounds of a selection/path in photoshop? I need to determine the proportions of a selection…

I can’t seem to get the syntax…

The local snippet (for context) is as follows:

if exists path item "Path 1" of document 1 then
	delete (every path item of document 1 whose name ≠ "Path 1")
	create selection path item "Path 1" of document 1
	do javascript "{var id128 = charIDToTypeID( \"Invs\" );

executeAction( id128, undefined, DialogModes.NO );}"

	fill selection of current document with contents {class:RGB color, red:255, green:255, blue:255}

        <<CODE TO GO HERE>>

end if

Thanks for any and all help…

Seth

One further thing…

I tried:

set boundsVal to properties of selection of document 1
return boundsVal

and got the following:

{bounds:missing value, container:document “garbage.eps” of application “Adobe Photoshop CS2”, best type:reference, default type:reference, class:selection-object}

… still trying…

Hi dialogal

check out this link http://bbs.applescript.net/viewtopic.php?id=5983 someone
was asking the same question nearly as you,

From what i gather it’s not that easy to return the bounds of a selection, however some dude on this link came up with this:

“That’s not something that is currently scriptable.
You can calculate the size of the current selection (by creating a new document with the contents and then getting the height/width of that), but you can’t get the selection points.”

Hope this helps a little.

From what I’ve seen elsewhere selection bounds was introduced not long ago either CS1 or 2 and has never worked as intended even in Java. Seems the easiest work around is to create new layer fill your selection get the bounds of the layer then throw it away. Here’s a snippet.

tell application "Adobe Photoshop CS"
	activate
	set docRef to the current document
	tell docRef
		tell path item 1
			create selection feather amount 0 with antialiasing
		end tell
		set savedState to current history state of docRef
		make new art layer at beginning of docRef with properties ¬
			{name:"Selection Bounds", blend mode:normal}
		set current layer to layer "Selection Bounds" of docRef
		fill selection with contents {class:RGB color, red:255, green:255, blue:255}
		set thebounds to bounds of layer "Selection Bounds"
		set current history state of docRef to savedState
	end tell
end tell

Having just dug out a copy of PS7, Mark, I can confirm that the selection property bounds is not available there. The same goes for container and default type.

tell application "Adobe Photoshop 7.0" to properties of selection of current document
--> {class:selection-object, best type:reference}