background-removal-js icon indicating copy to clipboard operation
background-removal-js copied to clipboard

Make it work in Node.js

Open BjoernRave opened this issue 1 year ago • 2 comments

I don't know how complicated this is, but it would be awesome if it would also work in node.js

BjoernRave avatar Jul 05 '23 13:07 BjoernRave

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.

liudonghua123 avatar Jul 07 '23 03:07 liudonghua123

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.

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.

chrxmvtik avatar Jul 08 '23 17:07 chrxmvtik

fyi. globalThis should be used instead of window or self

jimmywarting avatar Jul 10 '23 00:07 jimmywarting

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.

DanielHauschildt avatar Jul 16 '23 17:07 DanielHauschildt

There are also things such as node-canvas and skia-canvas for NodeJS

jimmywarting avatar Jul 16 '23 18:07 jimmywarting

Looking forward to the version of node. This tool is great ! ❤️

MuLoo avatar Jul 27 '23 03:07 MuLoo

Looking forward to the version of node.

maybeyourking avatar Aug 07 '23 11:08 maybeyourking

WIP https://github.com/imgly/background-removal-js/pull/26

DanielHauschildt avatar Aug 08 '23 14:08 DanielHauschildt

NodeJS version would be amazing 😁

AhmedAEB avatar Aug 12 '23 10:08 AhmedAEB

A node version would be soooo helpful.

jwagsters avatar Aug 18 '23 14:08 jwagsters

any update for node js? really excited.

djppnur avatar Aug 21 '23 09:08 djppnur

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.

Crashtor avatar Aug 30 '23 19:08 Crashtor

Fixed by #36

DanielHauschildt avatar Sep 12 '23 13:09 DanielHauschildt

Thanks for the great work! However, is it published on npm already?

https://github.com/imgly/background-removal-js/issues/38

edwinkcw avatar Sep 13 '23 03:09 edwinkcw