What version of Bun is running?
1.0.4+387f1260c9dc0cea667b44ec0152fff0cd4def25
What platform is your computer?
Darwin 21.6.0 x86_64 i386
What steps can reproduce the bug?
mkdir bun-bg-removal && cd $_
bun init
bun add --exact @imgly/background-removal-node sharp@0.32.6 # Avoid version mismatch between background-removal and sharp
Code of index.ts
import { removeBackground } from '@imgly/background-removal-node';
const url = 'https://balonmano.isquad.es/images/afiliacion_clubs/2898/square_35723432687275366a39.jpg';
try {
const imgBg = await removeBackground(url, {
model: 'medium',
progress: (key: any, current: any, total: any) => {
console.log(`Downloading ${key}: ${current} of ${total}`);
}
});
Bun.write('imgBg.png', imgBg);
} catch (error) {
console.log(error);
}
Sharp
I installed sharp because I though @imgly/background-removal-node was only accepting pngs so I tried also with this code in a new file called index.js:
import { removeBackground } from "@imgly/background-removal-node";
import sharp from "sharp";
const url =
"https://balonmano.isquad.es/images/afiliacion_clubs/2898/square_35723432687275366a39.jpg";
try {
const data = await fetch(url).then((response) => response.arrayBuffer());
const png = await sharp(data).png().toBuffer();
const imgBg = await removeBackground(png, {
model: "medium", // default but I want to be explicity with this
progress: (key, current, total) => {
console.log(`Downloading ${key}: ${current} of ${total}`);
},
});
sharp(imgBg).toFile("output.png");
} catch (error) {
console.log(error);
}
What is the expected behavior?
Create imgBg.png file with, at least, a try to remove background of the image or any issue with remove background package. If all goes right and model could remove the image background should be a transparent background png with the shield shape.
What do you see instead?
Downloading fetch:/models/medium: 16384 of 88188479
Downloading fetch:/models/medium: 88188479 of 88188479
[1] 69528 segmentation fault bun index.ts
Additional information
This package requires onnyxruntime-node which has opened issues due it does not work currently on bun:
My package of using the code can be wrong but if thats the case I think segfault is not an expected error BTW. If segfault can be an expected error then this issue I opened in the package repository should be tracked as well:
What version of Bun is running?
1.0.4+387f1260c9dc0cea667b44ec0152fff0cd4def25
What platform is your computer?
Darwin 21.6.0 x86_64 i386
What steps can reproduce the bug?
Code of
index.tsSharp
I installed sharp because I though
@imgly/background-removal-nodewas only accepting pngs so I tried also with this code in a new file calledindex.js:What is the expected behavior?
Create
imgBg.pngfile with, at least, a try to remove background of the image or any issue with remove background package. If all goes right and model could remove the image background should be a transparent background png with the shield shape.What do you see instead?
Additional information
This package requires
onnyxruntime-nodewhich has opened issues due it does not work currently on bun:onnxruntime-node#3574My package of using the code can be wrong but if thats the case I think segfault is not an expected error BTW. If segfault can be an expected error then this issue I opened in the package repository should be tracked as well: