From 4f0a778b9a75dd8868ef407f4f5a9bbed9e4fea3 Mon Sep 17 00:00:00 2001 From: yourfriendoss Date: Thu, 10 Jul 2025 19:21:35 +0300 Subject: [PATCH] add size changing --- index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 75ef6b4..bf5c546 100644 --- a/index.ts +++ b/index.ts @@ -25,14 +25,22 @@ app.post('/render', async (c) => { extraArgs = body.extraArgs; } + if(body.size) { + if (typeof body.size !== 'number' || ![32, 64, 128].includes(body.size)) { + return c.text('size must be one of 32, 64, or 128', 400) + } + joypixels.emojiSize = body.size.toString(); + } + const emojiHtml = joypixels.toImage(body.emoji) const urlMatch = emojiHtml.match(/src="([^"]*)"/) if (!urlMatch) { return c.text('Could not extract emoji URL', 500) } - const emojiUrl = urlMatch[1] - const filename = "cache/" + emojiUrl.split('/').pop() ; + let emojiUrl = urlMatch[1] + console.log(emojiUrl) + const filename = "cache/" + emojiUrl.split('/').pop().split(".")[0] + `-${joypixels.emojiSize}.png`; if(!existsSync(filename)) { // Download the image