add size changing
This commit is contained in:
parent
a66a344cc0
commit
4f0a778b9a
1 changed files with 10 additions and 2 deletions
12
index.ts
12
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue