Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -3,6 +3,8 @@ const { createCanvas, loadImage } = require('canvas');
|
|
| 3 |
const helmet = require('helmet');
|
| 4 |
const rateLimit = require('express-rate-limit')
|
| 5 |
const bodyParser = require('body-parser');
|
|
|
|
|
|
|
| 6 |
const app = express();
|
| 7 |
const port = 7860;
|
| 8 |
|
|
@@ -39,7 +41,7 @@ async function createCustomSWGenerator({ profileImage, mainImage, caption = "Cus
|
|
| 39 |
// Tambahkan gambar utama
|
| 40 |
if (mainImage) {
|
| 41 |
try {
|
| 42 |
-
const mainImg = await
|
| 43 |
ctx.drawImage(mainImg, 0, 200, canvasWidth, 1080);
|
| 44 |
} catch (error) {
|
| 45 |
console.error("Gagal memuat gambar utama:", error.message);
|
|
@@ -53,7 +55,7 @@ async function createCustomSWGenerator({ profileImage, mainImage, caption = "Cus
|
|
| 53 |
// Gambar profil dengan border putih
|
| 54 |
if (profileImage) {
|
| 55 |
try {
|
| 56 |
-
const profileImg = await
|
| 57 |
ctx.save();
|
| 58 |
ctx.beginPath();
|
| 59 |
ctx.arc(90, 90, 60, 0, Math.PI * 2);
|
|
|
|
| 3 |
const helmet = require('helmet');
|
| 4 |
const rateLimit = require('express-rate-limit')
|
| 5 |
const bodyParser = require('body-parser');
|
| 6 |
+
const path = require('path');
|
| 7 |
+
const loadImg = require('./loader');
|
| 8 |
const app = express();
|
| 9 |
const port = 7860;
|
| 10 |
|
|
|
|
| 41 |
// Tambahkan gambar utama
|
| 42 |
if (mainImage) {
|
| 43 |
try {
|
| 44 |
+
const mainImg = await loadImg(mainImage);
|
| 45 |
ctx.drawImage(mainImg, 0, 200, canvasWidth, 1080);
|
| 46 |
} catch (error) {
|
| 47 |
console.error("Gagal memuat gambar utama:", error.message);
|
|
|
|
| 55 |
// Gambar profil dengan border putih
|
| 56 |
if (profileImage) {
|
| 57 |
try {
|
| 58 |
+
const profileImg = await loadImg(profileImage);
|
| 59 |
ctx.save();
|
| 60 |
ctx.beginPath();
|
| 61 |
ctx.arc(90, 90, 60, 0, Math.PI * 2);
|