Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add a solid border without changing the overall size
#1
Photo 
I'm fairly new to Gimp, so this might be a straightforward answer.

I have a collection of images that are a solid color with transparent backgrounds.

https://imgur.com/a/mw6jj6x

This is a crude example. The left arrow is the type of image I have where Green is the solid color and White is transparent.

My goal is to add borders like the red in the example. 
The middle adds a single layer of pixels outside of the original, overwriting some transparency.
The right replaces the outermost layer of pixels with a new color without replacing any transparent pixels.

Clearly the optimal solution would work for any number of pixels.

The images are not simple polygons so I can't just use a specialized rectangle/circle/etc drawing tool.
I created the example by using the pencil tool and manually changing pixels to red. This is not feasible for larger images.

Also avoiding some sort of smoothing would be nice. I want the border to be a solid color. Any solutions that involve smoothing are still acceptable.

Thanks for any and all advice!
Reply
#2
Layer>Transparency>Alpha to selection, and do something with the outline of that selection:
  • Select>Border and bucket-fill: easiest, but you don't get sharp angles
  • Edit>Stroke selection (in Line mode, because using a brush will also prevent sharp angles)
  • Select>To path, Select>None, Edit>Stroke path: somewhat cleaner than Edit>Stroke selection
All these techniques create an outline that straddles the current border of your object. You can improve on them to keep the very same outline (the painting is done only inside) or to keep the current shape (painting is done outside) but there are small details that need to be taken in account for a correct result.

The  "Stroke path" method (in the three modes:  over, inside, outside) is used by my ofn-outline-layer script that you will find here.
Reply
#3
Using standard Gimp tools.

border around: 
Add a layer under the icon
Color select the icon
Grow the selection x pixels
Fill layer under icon
Turn selection off
merge layers

border inside:
Toggle alpha lock on
Color select icon
Shrink the selection x pixels
Invert the selection
Fill the selection
Turn selection off
Toggle alpha lock off

Example: 2 minutes https://youtu.be/YbS9dFhGOoQ



Reply


Forum Jump: