diff --git a/src/modules/utility/userinfo.js b/src/modules/utility/userinfo.js index 0066a82..b843b1b 100644 --- a/src/modules/utility/userinfo.js +++ b/src/modules/utility/userinfo.js @@ -72,16 +72,16 @@ async function fetchQuestData() { questsFetch = Date.now() + 60 * 60 * 1000; } -function nameplateBackground(color) { +function nameplateBackground(width, height, color, light = false) { return sharp( - Buffer.from(` + Buffer.from(` - + - + `) ); } @@ -515,13 +515,16 @@ userinfo.callback = async function (msg, line) { const static = await fetch(imageUrl) .then((res) => res.arrayBuffer()) .then((b) => Buffer.from(b)); + const metadata = sharp(static).metadata(); - const bg_light = nameplateBackground(palette.lightBackground); + const bg_light = nameplateBackground(metadata.width, metadata.height, palette.lightBackground, true); bg_light.composite([{input: static}]); - const bg_dark = nameplateBackground(palette.darkBackground); + const bg_dark = nameplateBackground(metadata.width, metadata.height, palette.darkBackground); bg_dark.composite([{input: static}]); - const final = sharp({create: {width: 448, height: 168, channels: 4, background: "transparent"}}); + const final = sharp({ + create: {width: metadata.width, height: metadata.height * 2, channels: 4, background: "transparent"}, + }); final.composite([ {input: await bg_light.toBuffer(), gravity: "north"}, {input: await bg_dark.toBuffer(), gravity: "south"}, @@ -552,6 +555,7 @@ userinfo.callback = async function (msg, line) { }, ], image: {url: imageUrl}, + footer: `SKU ID: ${nameplate.sku_id}`, }; }