imgly / background-removal-js

Remove backgrounds from images directly in the browser environment with ease and no additional costs or privacy concerns. Explore an interactive demo.
https://img.ly/showcases/cesdk/web/background-removal/web
GNU Affero General Public License v3.0
5.49k stars 339 forks source link

Exposing lower level apis, common package #57

Open TorbjornHoltmon opened 8 months ago

TorbjornHoltmon commented 8 months ago

Currently, background removal is a simple and intuitive function, which is great. But I find myself needing to be a little more flexible with how I use it, and I would like to use some of the core functionality.

I noticed that none of the lower level apis are exposed and that some of the code between web and node is duplicated.

Would you be open to a pull request to create a common package that exposes the core of background removal?

x-wink commented 8 months ago

I have the same suggestion,it's one time work now. maybe I want to manual adjust clip mask, this is a common need.

DanielHauschildt commented 8 months ago

Creating a common package it's a bit tricky due to some dependencies which are different.

I am open for a PR. I tried it for 2-3 hours once but problems kept popping up and it was not worth it.

DanielHauschildt commented 8 months ago

Also, I would seperate the concerns

  1. Expose low level API
  2. Single common package

What functions would you need. I might add a flag to export the mask instead of the finalized image.

x-wink commented 8 months ago

export the mask batter than finalized image, or both

TorbjornHoltmon commented 8 months ago

I looked at this for 2-3 hours yesterday.

Before I move forward with a PR I am curious how your publishing works. I can´t see any CI in GitHub actions. I also need to know how you want the packages to be linked, since you use npm I guess a workspace is necessary. I use PNPM myself, and I am not too familiar with npm workspaces. But my impression is it works very much the same. I don't want to spend a lot of time on changing the repo tooling if it is not welcome.

Edit:

I have to say this was a bigger undertaking than I first anticipated. I wanted the core functionality exposed, and my plan was to dependency inject anything node or web specific. It ended up messy. I am not the right person to look at this.