Spaces:
Paused
Paused
| const express = require("express"); | |
| const axios = require("axios"); | |
| const sharp = require("sharp"); | |
| const app = express(); | |
| const PORT = 7860; | |
| // GAMBAR ASLI (PAPAN SUDAH ADA DI GAMBAR) | |
| const IMAGE_URL = | |
| "https://i.ibb.co.com/m5Dkt0rc/4f8a05c3a4976286d18fd6b533306d9b.jpg"; // ganti ke link kamu | |
| app.get("/api", async (req, res) => { | |
| try { | |
| const text = req.query.text || "HALO"; | |
| const baseImg = await axios.get(IMAGE_URL, { | |
| responseType: "arraybuffer", | |
| }); | |
| // SVG SUPER JELAS (DEBUG MODE) | |
| const svg = ` | |
| <svg width="500" height="200" viewBox="0 0 500 200" | |
| xmlns="http://www.w3.org/2000/svg"> | |
| <style> | |
| text { | |
| fill: red; | |
| font-size: 48px; | |
| font-weight: 900; | |
| font-family: Arial, Helvetica, sans-serif; | |
| } | |
| </style> | |
| <text x="250" y="100" | |
| text-anchor="middle" | |
| dominant-baseline="middle"> | |
| ${text} | |
| </text> | |
| </svg>`; | |
| const output = await sharp(baseImg.data) | |
| .composite([ | |
| { | |
| input: Buffer.from(svg), | |
| // ⬇️ POSISI TENGAH PAPAN (SUDAH DISAMAKAN) | |
| left: 560, | |
| top: 230, | |
| }, | |
| ]) | |
| .png(); | |
| res.set("Content-Type", "image/png"); | |
| output.pipe(res); | |
| } catch (e) { | |
| console.error(e); | |
| res.status(500).send("error"); | |
| } | |
| }); | |
| app.listen(PORT, () => | |
| console.log("AnimeBrat API running on " + PORT) | |
| ); |