From 2d48a3bd25decd2fe53311bf3513754fae564465 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Thu, 16 Mar 2023 19:38:16 +0200 Subject: [PATCH] Fix images getting squeezed when resized --- server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index f8143f43a..399ffce4d 100644 --- a/server.js +++ b/server.js @@ -626,7 +626,7 @@ async function charaWrite(img_url, data, target_img, response = undefined, mes = try { // Read the image, resize, and save it as a PNG into the buffer const rawImg = await jimp.read(img_url); - const image = await rawImg.resize(400, 600).getBufferAsync(jimp.MIME_PNG); + const image = await rawImg.cover(400, 600).getBufferAsync(jimp.MIME_PNG); // Get the chunks const chunks = extract(image); @@ -1372,7 +1372,7 @@ app.post('/uploaduseravatar', urlencodedParser, async (request, response) => { try { const pathToUpload = path.join('./uploads/' + request.file.filename); const rawImg = await jimp.read(pathToUpload); - const image = await rawImg.resize(400, 400).getBufferAsync(jimp.MIME_PNG); + const image = await rawImg.cover(400, 400).getBufferAsync(jimp.MIME_PNG); const filename = `${Date.now()}.png`; const pathToNewFile = path.join(directories.avatars, filename);