@xuda.io/account_module 1.2.244 → 1.2.246
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +10 -2
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1546,12 +1546,20 @@ export const get_user_name = async function (uid) {
|
|
|
1546
1546
|
}
|
|
1547
1547
|
};
|
|
1548
1548
|
|
|
1549
|
-
const removeBg = async function (inputPath, outputPath) {
|
|
1549
|
+
const removeBg = async function (inputPath, url, outputPath) {
|
|
1550
1550
|
try {
|
|
1551
1551
|
// Load image from file
|
|
1552
|
-
const imageBuffer = fs.readFileSync(inputPath);
|
|
1552
|
+
// const imageBuffer = fs.readFileSync(inputPath);
|
|
1553
1553
|
|
|
1554
1554
|
// Remove background (returns a Blob)
|
|
1555
|
+
|
|
1556
|
+
const res = await fetch(imgObj.url);
|
|
1557
|
+
if (!res.ok) {
|
|
1558
|
+
throw new Error(`Failed to fetch image URL: ${res.status} ${res.statusText}`);
|
|
1559
|
+
}
|
|
1560
|
+
const arrayBuffer = await res.arrayBuffer();
|
|
1561
|
+
const fullImgBuffer = Buffer.from(arrayBuffer);
|
|
1562
|
+
|
|
1555
1563
|
const blob = await removeBackground(imageBuffer);
|
|
1556
1564
|
|
|
1557
1565
|
// Convert to buffer and save
|