Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add contour? #4010

Closed
1923trk opened this issue Jun 18, 2024 · 1 comment
Closed

How to add contour? #4010

1923trk opened this issue Jun 18, 2024 · 1 comment

Comments

@1923trk
Copy link

1923trk commented Jun 18, 2024

Hello, Thank you for the library.
I have png images with alpha channels. I want to add contours to these images and get a result like the examples I will share below, but I couldn't find how to do it. Additionally I should be able to control the background color.
54
24061513YKHV-01cqkdy8yiiputopi8le3xut
169
24061513YKGS-t7qy707avbs1bx3p82webwwq

@kipcole9
Copy link

I think this should move to a discussion rather than an issue.

I'm no expert but I believe the approach you can take is this:

  1. Take your alpha band and dilate it. Dilation will add edge pixels to represent the contour.
  2. Take a copy of this dilated alpha band and colour it any way you want
  3. Compose the base image over the coloured contour image
  4. Add the dilated alpha band to re-establish the transparency.

I can see in your examples you have both a white border and then a feathered dark edge. You can use variations of the above to use more composed layers to get that effect. For example, to get the feathered edge, you can duplicate the dilated alpha band again and use a gaussian blur on it.

I'm sure John and Kleis can be more precise but they are in difference time zones - please take the above as a possible path from someone who is also learning how to do this kind of thing.

@libvips libvips locked and limited conversation to collaborators Jun 18, 2024
@jcupitt jcupitt converted this issue into discussion #4011 Jun 18, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants