background-removal-js
background-removal-js copied to clipboard
Make it work in Node.js
I don't know how complicated this is, but it would be awesome if it would also work in node.js
I have run into the same problems. The browser.{js,mjs}
uses some web api like self
, window
, window.location.href
and so on.
It would be nice if it support browser/node/deno environments.
I have run into the same problems. The
browser.{js,mjs}
uses some web api likeself
,window
,window.location.href
and so on.It would be nice if it support browser/node/deno environments.
You can modify webpack config file to get rid of those errors, simply change target to 'node' in umdConfig then build package. It will not be node-only without canvas, etc. But it will work if you want to implement background removal as is in the example package.
fyi. globalThis
should be used instead of window
or self
Making it work on Node.js would require porting parts of the utils.ts
. I think most of the functions required like image resize and png/jpeg encode/decode can be achieved by Jimp
.
The onnx-runtime
also has a Node.js version.
There are also things such as node-canvas and skia-canvas for NodeJS
Looking forward to the version of node. This tool is great ! ❤️
Looking forward to the version of node.
WIP https://github.com/imgly/background-removal-js/pull/26
NodeJS version would be amazing 😁
A node version would be soooo helpful.
any update for node js? really excited.
Any update/ETA on this? I'm very interested in this as the IMG.ly PESDK for React Native (or any other framework except iOS / Android) doesn't seem to allow headless rendering or to "programatically edit" an image without going through the editor UI. And since our organisation needs only to utilise the background removal feature, this would be amazing.
Fixed by #36
Thanks for the great work! However, is it published on npm already?
https://github.com/imgly/background-removal-js/issues/38