can i remove a background from an image using Js
hey guy i was wondering if i can create a javascript api that removes the background from an Image , does js have that capability ?
18 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
does js has that capability anyways ?
This could be useful: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Manipulating_video_using_canvas
Manipulating video using canvas - Web APIs | MDN
By combining the capabilities of the video element with a canvas, you can manipulate video data in real time to incorporate a variety of visual effects to the video being displayed. This tutorial demonstrates how to perform chroma-keying (also known as the "green screen effect") using JavaScript code.
basically you will want to load the image, loop through the image data replacing remove colors matching your "background" color with transparency while copying everything to a new array of image data, then redraw that imagedata to a new canvas and export it
any solution involving canvas didn't work 😔
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
what didnt work about canvas? if you ran into a tainted canvas issue there are ways to resolve that
the output was a disaster plus is canvas the only way to do it ?
Canvas is the only way I know if you want pure browser JS. But if you want to host a server you can do that.
what's the best way to find another solution ?
I hate to be that person but we've given you all the ways we know to do this. If the output was pure disaster you may have been doing it wrong
well maybe ur right
it's fine don't hate yourself sry if i made u feel that way it
Canvas is the way to go about it like @Lizzy A mentioned
Now if you can't achieve it then use a paid service https://clipdrop.co/apis/docs/remove-background#:~:text=Remove%20Background%20API%E2%80%8B,the%20original%20image%20to%20process.
Remove Background | ClipDrop APIs
Quickly remove the background of any image with incredible accuracy
it works with very small images if it gets to certain size it looks so bad
i have already tried that i am refering to canvas here
I recommend googling "what is a threshold"
Specifically search for mathematical results
As the only way I can see the output looking disgusting is if you only removed a pure color like #ffffff
Photos blend all the time so this is why you say "anything above 95% this color" for example
Photoshop used a similar method for magic selects back in the day iirc
so u believe that made a mistake somewhere ?
i believe that if you aren't already using a threshold value you should be, and if you aren't that's why you're getting garbage results
i never used canvas before that was my first time i found it a bit difficult to understand some of the stuff related to it or i just got bored from trying and getting bad results