5

hello

I need to create in javascript something to change a color to transparent, on PNG
I'd like to create a form that, when I post a picture, everything white should be transformed to transparent and generated as a new PNG, however this white is coming from a picture so it won't be exactly white
but contrast are good since this will pictures of text written on a white page
maybe some king of green screen algo

any ideas on how to do that ?

you are viewing a single comment's thread
view the rest of the comments
[-] OwOarchist@pawb.social 3 points 2 days ago* (last edited 2 days ago)

where tolerance is some fairly small number, maybe 5

If this is to be part of a user-submitted form, maybe set a sane default, but let the user decide exactly where to set the limit -- because it will change depending on the particular image being worked on. Some need a high tolerance because the white background isn't very close to true white, others need a low tolerance because the foreground you want to keep has highlights that are too close to white. So you give the form an extra control slider to change the tolerance between, say, 1 and 30, with it defaulting to, say, 5.

this post was submitted on 27 Aug 2026
5 points (100.0% liked)

JavaScript

2785 readers
6 users here now

founded 3 years ago
MODERATORS