Added custom banner

This commit is contained in:
CorwinDev committed 2022-08-16 10:53:33 +02:00
1 parent 87eb1f3a9c
commit 0130b3c9af
1 file changed
+10 -2
+10 -2
View File
@@ -66,12 +66,20 @@ router.get('/server/banner/:id', function (req, res) {
// Draw the image // Draw the image
const canvas = createCanvas(700, 250); const canvas = createCanvas(700, 250);
const context = canvas.getContext('2d'); const context = canvas.getContext('2d');
if (req.query.background) {
try {
const background = await loadImage(req.query.background)
context.drawImage(background, 0, 0, canvas.width, canvas.height);
} catch (e) {
res.send("Invalid Background")
return
}
} else {
const background = await readFile('./website/public/img/wallpaper.jpg'); const background = await readFile('./website/public/img/wallpaper.jpg');
const backgroundImage = new Image(); const backgroundImage = new Image();
backgroundImage.src = background; backgroundImage.src = background;
context.drawImage(backgroundImage, 0, 0, canvas.width, canvas.height); context.drawImage(backgroundImage, 0, 0, canvas.width, canvas.height);
}
context.strokeStyle = '#0099ff'; context.strokeStyle = '#0099ff';
context.strokeRect(0, 0, canvas.width, canvas.height); context.strokeRect(0, 0, canvas.width, canvas.height);