@xuda.io/account_module 1.2.247 → 1.2.249
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 +7 -7
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1552,15 +1552,15 @@ const removeBg = async function (inputPath, url, outputPath) {
|
|
|
1552
1552
|
if (inputPath) {
|
|
1553
1553
|
imageBuffer = fs.readFileSync(inputPath);
|
|
1554
1554
|
}
|
|
1555
|
-
// Remove background (returns a Blob)
|
|
1556
1555
|
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1556
|
+
if (url) {
|
|
1557
|
+
const res = await fetch(imgObj.url);
|
|
1558
|
+
if (!res.ok) {
|
|
1559
|
+
throw new Error(`Failed to fetch image URL: ${res.status} ${res.statusText}`);
|
|
1560
|
+
}
|
|
1561
|
+
const arrayBuffer = await res.arrayBuffer();
|
|
1562
|
+
imageBuffer = Buffer.from(arrayBuffer);
|
|
1560
1563
|
}
|
|
1561
|
-
const arrayBuffer = await res.arrayBuffer();
|
|
1562
|
-
const fullImgBuffer = Buffer.from(arrayBuffer);
|
|
1563
|
-
|
|
1564
1564
|
const blob = await removeBackground(imageBuffer);
|
|
1565
1565
|
|
|
1566
1566
|
// Convert to buffer and save
|