Spaces:
Paused
Paused
Update loader.js
Browse files
loader.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
const fs = require('fs');
|
| 2 |
const path = require('path');
|
| 3 |
const fetch = require('node-fetch'); // Pastikan ini diinstal
|
| 4 |
-
const { Image } = require('canvas');
|
| 5 |
|
| 6 |
// Fungsi untuk memuat gambar dari URL atau jalur file lokal
|
| 7 |
async function loadImg(source) {
|
|
@@ -25,9 +25,7 @@ async function loadImg(source) {
|
|
| 25 |
if (!fs.existsSync(filePath)) {
|
| 26 |
throw new Error(`File tidak ditemukan di jalur: ${filePath}`);
|
| 27 |
}
|
| 28 |
-
const
|
| 29 |
-
const img = new Image();
|
| 30 |
-
img.src = buffer;
|
| 31 |
return img;
|
| 32 |
}
|
| 33 |
} catch (error) {
|
|
|
|
| 1 |
const fs = require('fs');
|
| 2 |
const path = require('path');
|
| 3 |
const fetch = require('node-fetch'); // Pastikan ini diinstal
|
| 4 |
+
const { Image, loadImage } = require('canvas');
|
| 5 |
|
| 6 |
// Fungsi untuk memuat gambar dari URL atau jalur file lokal
|
| 7 |
async function loadImg(source) {
|
|
|
|
| 25 |
if (!fs.existsSync(filePath)) {
|
| 26 |
throw new Error(`File tidak ditemukan di jalur: ${filePath}`);
|
| 27 |
}
|
| 28 |
+
const img = await loadImage(filePath);
|
|
|
|
|
|
|
| 29 |
return img;
|
| 30 |
}
|
| 31 |
} catch (error) {
|