0

I've got an image of several irregular shapes on white background.

(.=white)
......................
......................
.....11.....22222.....
....111.......22222...
...111................
.....1................
......................

I want to create several other files, each containing one shape from the original image, placed on the transparent background.

(.=transparent)
......
...11.
..111.
.111..
...1..
......

So far the solution is easy: use Free Select Tool on each shape, Copy, create a new file, in Advanced Options select "Fill with Transparency", Paste, Image -> Autocrop Image.

Here's where my complications arises. These output shapes will be placed on another picture, quite colorful, and if these files are created like this, they are visible very poorly due to colors meshing. I'd like to create a border around each shape that is exact shape of my freeform selection. How can I do that?

A simple answer - use a paintbrush and trace the line again - isn't satisfying because my hand won't repeat exact same shapes, so the border will be jaggy.

A border tool isn't adequate because it creates a simple-minded rectangular border, while I want a free-form shape one. Various Edge-Detect filters seem to make out the shapes, but then they mangle the colors on them.

Thanks for your help!

2
  • Is the edge of each shape sharp and aliased to individual pixels, i.e. there is no mix of colors 1 and 2 with the white there; and the white is uniform #ffffff white? Commented Dec 15, 2016 at 22:32
  • White is uniform, but between an image edge and the background there's a slight aliasing, as the picture comes from a photo (of a miniature).
    – Arry
    Commented Dec 20, 2016 at 20:19

1 Answer 1

1

To get a clean transparent background:

  • Layer>Transparency>Add alpha channel (if there is not one already)
  • Select the background with the fuzzy selector and a low threshold. Increase the threshold just to include background irregularities such as JPEG artefacts.
  • Select>Grow by two pixels.
  • Color>Color to Alpha and remove the white. You should end up with your shapes cleanly cut out.

Then do a rectangular selection around the shapes and copy/paste each to new files (typically, Edit>Copy and File>Create from clipboard or Edit>Paste as new image).

To add an outline, in each shape image obtained:

  • Layer>Transparency>Alpha to selection (this create a selection from the shape)
  • Select>To path (makes a path from the selection)
  • Select>None (important!)

Then:

  • If you want the outline to straddle the edge of the shape, use Edit>Stroke path in "line" mode
  • If you want the outline completely inside the shape:
    • Set the alpha-lock on the layer
    • Edit>Stroke path and give a width double of what you want

If you want to add the very same outline to all shapes, once the background has been removed you can use the procedure above one the initial image to add the outline to all the shapes in one go.

1
  • Thanks for a detailed response! That's exactly what I needed.
    – Arry
    Commented Dec 20, 2016 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.