What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Make precise rectangular selection around object in photoshop.


PutinHuilo

Well-Known Member
Messages
65
Likes
0
Here's my project (PSD attached) i have 2 objects on separate layers, first one is blue box you know when you Ctrl+Left Mouse Click blue box layer in "Layers" window it will make selection around blue box following its shape in this case it will make rectangular selection around blue box.
And when you do same for green object layer it will make selection that follows exact shape of the green object.

What i need to do is find a way to make a rectangular selection around the green object that will precisely fit edges of object like example shown in the image below.
Is there automatic way to do this versus doing it by hand?
1.jpg
Here's a long way to get what i want, wonder if there's faster solution?
- select green object and Ctrl+C
- create new image (it be sized automatically to fix copied object)
- paste green object to new image
- change background color to something different so when i go to Image > Convas Size and increase image size new area will have different background color
- use Magic Wand (W) tool to select the white background under the green shape.
rectangle.png
 

Attachments

Last edited:
This is not very "automatic", but here's a convoluted way to arrive at what you're trying to do. If you activate the layer with your green shape and select Edit>Transform>Scale, a sizing rectangle is formed around the shape and there is data displayed showing the exact pixel dimensions of that rectangle (see red arrows in the image below). Once you know these exact pixel dimensions, you can then use the rectangular shape tool on a new layer to create a rectangle then re-size it (Edit>Transform>Scale) to those exact pixel dimensions. Once you've got that, you can create a selection from that layer which will exactly fit your irregular green shape.

Untitled-2.jpg
 
Use Image->Trim to trim away all totally transparent pixels from all sides.
BTW, this will let you find the bounding rectangle even for objects with feathered edges.
 
Why photoshop is so primitive man they add tons of filters and useless features, but some not so common features are nowhere to be found and you have to make workarounds for it...
 
Okay managed to find a simple and efficient solution if someone needs it i attached the action script file, will not make each step description, but idea is like this.

Info.jpg
 

Attachments

Still another recordable way using Smart Objects:
1. Duplicate your layer
2. Turn it to Smart Object
3. Open SO for editing. In SO contents document add a new layer, Select All, Fill with some color, save
4. Close SO document
5. Select SO transparancy(Ctrl-Click on it) in the main document
6. Delete SO layer
 
And yet another way

I am assuming each object is surrounded by transparency in each Layer yet could work with slight modifications to this approach if not

1) Create a blank Layer and fill with white (arbitrary pixel filled Layer) and turn off visibility for that Layer
2) With Layer of desired Object selected, use Cmd+click Layer thumbnail (Cntl for PC) to select the arbitrary shaped object
3) Select Crop Tool (it will provide square around object)
4) Make sure "Delete Cropped Pixels" Option is turned off and type Return (enter on PC) twice to accept the crop
5) Cmd +A (Cntl for PC) to make selection around object
6) Use Image > Reveal All
7) Delete filled arbitrary Layer from #1 if desired)

You should now have the full original image with a rectangular selection around the desired object. The filled arbitrary Layer is needed because the Reveal All step will not enlarge to the original dimensions if the crop only involved transparent pixels.

This works for my anyways and hope it is of interest

John Wheeler
 
here is a script solution which you can also include in action, make selection of layer transparency as you do it normally and then run the script ;)

JavaScript:
var Sel = new Array();
Sel = activeDocument.selection.bounds;

app.activeDocument.selection.select([ [Sel[2],Sel[1]], [Sel[2],Sel[3]], [Sel[0],Sel[3]], [Sel[0],Sel[1]] ]);

Hop that helps ;)
 

Back
Top