SHARP - Remove Uploaded Image Background

Looking how to use Sharp (or other free JS method) to remove an image’s background color and make it transparent.

Our customers will upload an image (typically with a white background) and I’m looking to simply remove this and replace with transparent background and save the file.

It seems like it might be possible with SHARP…

  • options.background - background colour, parsed by the defaults to white without transparency. (optional, default {r:255,g:255,b:255,alpha:1} )

Is there a way to test this or any other methods you’ve found that work successfully without paying for an API like remove.bg?

Thanks!

I’ve checked the sharp documentation and didn’t find a method to convert a color to transparent.