Tuesday, January 19, 2016

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; 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:
enter image description here



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


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.



Answer



enter image description here


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.


No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...