add size changing

This commit is contained in:
Soph :3 2025-07-10 19:21:35 +03:00
parent a66a344cc0
commit 4f0a778b9a

View file

@ -25,14 +25,22 @@ app.post('/render', async (c) => {
extraArgs = body.extraArgs; 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 emojiHtml = joypixels.toImage(body.emoji)
const urlMatch = emojiHtml.match(/src="([^"]*)"/) const urlMatch = emojiHtml.match(/src="([^"]*)"/)
if (!urlMatch) { if (!urlMatch) {
return c.text('Could not extract emoji URL', 500) 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)) { if(!existsSync(filename)) {
// Download the image // Download the image