1

I'm trying to fade the edges of an image that has a transparent background.
Is there a way to do this in Python using the PIL library?

I tried using the ImageFilter.BLUR filter but I can't seem to find a way to fade the edges only.

Sam Matar
  • 43
  • 4
  • 1
    Are you trying to blur the edges of the subject of the image or the edges of the whole picture (including transparent background)? – SanguineL Jun 02 '23 at 12:56
  • @SanguineL I'm trying to blur the edges of the subject of the image, it's a non-rectangular shape basically. – Sam Matar Jun 02 '23 at 13:03
  • Have you seen [this answer](https://stackoverflow.com/a/55068554/9731347)? Perhaps it is what you are looking for. – SanguineL Jun 02 '23 at 13:25
  • @SanguineL yes I've seen it, however, it uses OpenCV and I'm looking for a way to get a similar effect using PIL. – Sam Matar Jun 02 '23 at 13:29
  • I mean unless you have a legitimate reason not to use OpenCV, it really is the best way to go about doing that. There is an ImageFilter.filter(FIND_EDGES) method that can be used to create a mask, which you could then blur and combine with the original image, but I had some trouble while attempting that (mostly because the FIND_EDGES method does not have a width parameter as OpenCV does). – SanguineL Jun 02 '23 at 14:15

0 Answers0