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;
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue