Tips & Tricks - Adding a Border to a Layered File

7 Sep 2010 - 23:20
Adding a Border to a Layered File
Adding borders to a project is a common task in Photoshop. Often it can be done with relative ease; especially if the image is flat (meaning it contains one layer). Other times though, if the image has multiple layers that float and expand outside the boundaries it can be an altogether different story. Since both scenarios crop up from time to time I decided to write a solution to both, first the simple flattened image, then the more thought provoking layered file.
 
Before we get too involved with the terminology here I thought it would be helpful to point out that a border is called a stroke in Photoshop. If you want to add a one pixel blue border around a layer or whole image file, what you actually want to do in Photoshop’s world is add a stroke. Now you know what the stroke command does, right?
 
Focus your attention below where you should see a rather nice looking graphic depicting two large birds and a spotlight-driven, cloud filled background.
 
Adding a Border to a Layered File
 
Now if this were a flat file we were looking at, one which contained just a single solitary background layer, things would be simple. Follow these steps to add a border around the image-

Step One

 
First of all make sure the one layer you do have is set as a floating layer, and not the locked background layer. If you see a padlock icon next to the layer name, which will also be a dead give-away since it will be named 'Background', you'll need to double click it to rename and restructure it as a floating layer.

Step Two

Go to the Edit menu and choose 'Outline (stroke) Selection'. This will bring up the stroke dialogue box as seen below-
 
Stroke Dialogue Box
 
Change the width and colour to whatever you please, set the location to 'inside' as a border outside the image will not be visible, and a border on centre will only be 50% visible as half of it will fall outside the image, leave all the blending options alone and click OK. And there we go, you're image now has a border of your required colour and thickness around the image. Simple as that. Now for those occasions where things are slightly more complicated.
 
For the next problem we'll use exactly the same image file, only difference will be that we're now using layers. I've taken a screenshot of the layers panel below so you can see our starting point.
 
Layers Panel
 
Now of course we have a slightly different problem, if we select a layer and add a stroke to it, the stroke appears around the confines of the layer itself not the whole image. That problem is apparent by trying it on one of the bird layers. Instead of a border around the image; we get a border around the bird.
 
If we select the ‘clouds’ layer, or ‘lighting’ layer, the expectation would be for them to solve the problem and deliver the type of stroke we're after; after all, those layers encompass the entire image so adding a stroke to them should have the same result as we achieved in the previous example. Well it does but anywhere a layer higher up the pecking order obstructs it, we lose the border because it becomes hidden by the layer in front. If we move the clouds or lighting layer up to the top, we hide all the layers below and suddenly our image no longer makes sense. So how do we get around this little dilemma?

Step One

Activate the highest layer in the stack by clicking on it, and then hit the new layer icon at the bottom of the layers panel to add a new, blank layer. This layer, of course, should be at the top of the stack. If it isn't then go ahead and drag it there.

Step Two

We need to select the entire image, so go up to the ‘Select’ menu and choose ‘All’.

Step Three

Now we need to contract that selection outline by the number of pixels you want the border to be. Go back up to the ‘Select’ menu, choose ‘Modify’, and choose ‘Contract’. Enter the number of pixels you want your border to be. I'm going for a value of 2 pixels as you can see below.
 
Contract Selection Dialogue Box
 

Step Four

 
We currently have the area selected that we do not want to be affected by the stroke, and we need the opposite to be true. To select everything that isn't currently selected, and deselect everything that is currently selected we need to inverse the selection outline. To achieve this, go back up to the ‘Select’ menu and choose the ‘Inverse’ command.

Step Five

With the blank layer active, and the area we want as a border selected, come back up to the ‘Edit’ menu and choose the ‘Fill Selection’ command. You should see the following dialogue box-
 
Fill Layer Dialogue Box
 
Go ahead and choose the contents of your choice, this will be the colour of the stroke. Leave the blending alone for the time being and hit OK.

Step Six

Finally come back up to the ‘Select’ menu and choose the ‘Deselect’ command. You should be able to see the result on screen - a custom coloured and sized stroke around the perimeter of the image.
 
If you were in any doubt of the final effect, here it is below-
 
Adding a Border to a Layered File
 
I hope you've enjoyed the tutorial, and it comes in handy sooner rather than later.

 

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p>
  • You may quote other posts using [quote] tags.
  • Lines and paragraphs break automatically.
  • You can use BBCode tags in the text. URLs will automatically be converted to links.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.

Excellent Tutorial

Thank you so much. This is something that I never actually thought of doing, but after viewing this, I can think of all kinds of uses for it.

Matt's picture

Thanks

Thanks for your comment, I'm glad you liked it!