From f71636e37636f07b9aee0837e3291061945938e1 Mon Sep 17 00:00:00 2001 From: Trivernis Date: Thu, 9 Jan 2020 17:46:58 +0100 Subject: [PATCH] Optimize profilePicture quality and size - Optimize size by increasing the effort from 4 to 6 - Optimize quality with smartSubsampling --- src/routes/UploadRoute.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/UploadRoute.ts b/src/routes/UploadRoute.ts index 2ac1804..d65f947 100644 --- a/src/routes/UploadRoute.ts +++ b/src/routes/UploadRoute.ts @@ -105,12 +105,12 @@ export class UploadRoute extends Route { await sharp(profilePic.data) .resize(512, 512) .normalise() - .webp() + .webp({smartSubsample: true, reductionEffort: 6}) .toFile(filePath); fileName = `/${dataDirName}/${fileBasename}`; const user = await User.findByPk(request.session.userId); const oldProfilePicture = path.join(this.dataDir, path.basename(user.profilePicture)); - if ((await fsx.pathExists(oldProfilePicture))) { + if (await fsx.pathExists(oldProfilePicture)) { await fsx.unlink(oldProfilePicture); } else { globals.logger.warn(`Could not delete ${oldProfilePicture}: Not found!`);