Mobile app version of vmapp.org
Login or Join
Twilah924

: How to place a border around a picture with transparency in Photoshop? I have an image I want to draw a 1px black border around. When I increase the canvas size the extra space will be transparent;

@Twilah924

Posted in: #AdobePhotoshop #Transparency

I have an image I want to draw a 1px black border around. When I increase the canvas size the extra space will be transparent; I can't select a color here. Ordinarily I would increase the canvas by 2 transparent pixels, then placing a solid black layer underneath would do the trick.

However, my picture is a graph in PNG with a transparent background. If I try the above the whole background will turn black. How can I draw a border around a transparent image?

The original:


What happens if I enlarge by 1 (equally transparent) pixel around and slide a solid black layer underneath:


This is perfectly to be expected. If the original didn't have transparency only the extra pixels at the border would show in black. Hope this makes it more clear.

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Twilah924

4 Comments

Sorted by latest first Latest Oldest Best

 

@Jamie315

Step-by-step:


Open PNG in Photoshop (example: 10x10 PNG with black circle in center)
Add a new layer. This will be called layer 1. (Ctrl + Shift + N)
Fill in with any color (Alt + Backspace)
Expand canvas to desired size. The caveat is that the amount of increase on each side should be equal to the border thickness you want. In my example, I increase canvas size from 10x10 to 14x14, meaning 2 pz border on each side. (Image -> Canvas Size... : Ctrl + Alt + C)
Make a new layer. This will be called layer 2. (Ctrl + Shift + N)
Select all (Ctrl + A)
Subtract selection from layer 1 (Ctrl+ Alt-click on layer 1 thumbnail)
Fill in layer 2 (Alt + Backspace) and turn off visibility for layer 1. Layer 2 is your 2px border.
Delete layer 1, merge Layer 0 and Layer 2. (Ctrl + E)
The final image:


This seems long, but is actually a very short process. If you're working with many PNGs, and all your PNGs are the same size, then you can record an action for this.

a. Open the action window.
b. Click the "new action" button.
c. Enter name and shortcut key combination (let's say Ctrl + Shift + F5) for the action and press "Record".
d. Repeat steps 1-9 above. Tip: In step 4, enter a percentage value instead of a pixel value if you want this to work for any PNG size. Although doing this will not ensure same thickness border for all images.
e. Stop recording the action.
f. Open any other PNG of the same dimension and press the shortcut (Ctrl + Shift + F5), Photoshop will do the work for you.

Hope this helps.
Payod.

10% popularity Vote Up Vote Down


 

@Twilah924

Here's how I did it (I'll explain for an original of 298x198:


enlarge the original by 1 pixel on all sides -> 300x200
create e new image, white, 298x198
increase this to 300x200. Since we're on the background layer here we can select a black border
create layer from background, so that we can add transparency
select white area (magic wand) and delete. We now have a transparent image with a black border
paste the actual image as new layer
merge down (don't flatten, that would remove the transparency)


This works, but while it doesn't take as long as writing it all down I feel there has to be a better way. I simply can't understand why you can only select a color when you enlarge the background. There's no reason for it. Adobe, please let us choose between transparency and a solid color for common layers too.

10% popularity Vote Up Vote Down


 

@Jamie315

As far as I understand your problem, all you need is to find an easy way to erase the area that is used by your image from the background layer. What you could try is:


Select your backgroundlayer
Select all (Cmd + A)
Hold Cmd and alt keys and Click on your image layer (the area filled by the image will be cropped from your selection)
or
decrease the size of your selection by 2px
Delete the selected area from your background

10% popularity Vote Up Vote Down


 

@Cofer715

I think the best way of doing this is by using the single column/row marquee tool then just select all the excess and delete it. I'm not sure if it's gonna be a pixel-sized border but I hope this is what you're looking for.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme