Update index.js
Browse files
index.js
CHANGED
|
@@ -991,14 +991,13 @@ return res.json({message: "Success", code: 200, data:data})
|
|
| 991 |
const inputUrl = (await axios.get(url, {
|
| 992 |
responseType: 'arraybuffer' // Set response type ke 'arraybuffer' untuk mendapatkan buffer
|
| 993 |
})).data
|
| 994 |
-
|
| 995 |
-
const output = await transparentBackground(Buffer.from(inputUrl), "png", {
|
| 996 |
// uses a 1024x1024 model by default
|
| 997 |
// enabling fast uses a 384x384 model instead
|
| 998 |
fast: false,
|
| 999 |
});
|
| 1000 |
// res.set('Content-Type', 'application/octet-stream'); // Set content type untuk buffer
|
| 1001 |
-
return res.json({message:"Success", code : 200, data: await fileDitch(output)});
|
| 1002 |
} catch (e) {
|
| 1003 |
console.log(e);
|
| 1004 |
return res.json({ message: "Internal Server Error",
|
|
|
|
| 991 |
const inputUrl = (await axios.get(url, {
|
| 992 |
responseType: 'arraybuffer' // Set response type ke 'arraybuffer' untuk mendapatkan buffer
|
| 993 |
})).data
|
| 994 |
+
const output = await transparentBackground(inputUrl, await (await(await import('file-type')).fileTypeFromBuffer(inputUrl))?.ext || "png", {
|
|
|
|
| 995 |
// uses a 1024x1024 model by default
|
| 996 |
// enabling fast uses a 384x384 model instead
|
| 997 |
fast: false,
|
| 998 |
});
|
| 999 |
// res.set('Content-Type', 'application/octet-stream'); // Set content type untuk buffer
|
| 1000 |
+
return res.json({message:"Success", code : 200, data: await fileDitch(output, await (await(await import('file-type')).fileTypeFromBuffer(inputUrl))?.ext || "png")});
|
| 1001 |
} catch (e) {
|
| 1002 |
console.log(e);
|
| 1003 |
return res.json({ message: "Internal Server Error",
|