From 2c84c93f3d9262047963dd31b9a3c47f22f802d9 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 16 Sep 2023 21:53:30 +0300 Subject: [PATCH] Add thumbnails quality config --- default/config.conf | 3 ++- public/scripts/RossAscends-mods.js | 2 +- src/thumbnails.js | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/default/config.conf b/default/config.conf index e1bb5b1e3..4c629e402 100644 --- a/default/config.conf +++ b/default/config.conf @@ -9,7 +9,7 @@ const enableExtensions = true; //Enables support for TavernAI-extras project const listen = true; // If true, Can be access from other device or PC. otherwise can be access only from hosting machine. const allowKeysExposure = false; // If true, private API keys could be fetched to the frontend. const skipContentCheck = false; // If true, no new default content will be delivered to you. - +const thumbnailsQuality = 95; // Quality of thumbnails. 0-100 // If true, Allows insecure settings for listen, whitelist, and authentication. // Change this setting only on "trusted networks". Do not change this value unless you are aware of the issues that can arise from changing this setting and configuring a insecure setting. @@ -47,5 +47,6 @@ module.exports = { securityOverride, skipContentCheck, requestOverrides, + thumbnailsQuality, extras, }; diff --git a/public/scripts/RossAscends-mods.js b/public/scripts/RossAscends-mods.js index c01b05745..205c35aa0 100644 --- a/public/scripts/RossAscends-mods.js +++ b/public/scripts/RossAscends-mods.js @@ -338,7 +338,7 @@ export async function favsToHotswap() { // don't fill leftover spaces with avatar placeholders // just evenly space the selected avatars instead - /* + /* if (count < maxCount) { //if any space is left over let leftOverSlots = maxCount - count; for (let i = 1; i <= leftOverSlots; i++) { diff --git a/src/thumbnails.js b/src/thumbnails.js index 2d681ad78..db464008b 100644 --- a/src/thumbnails.js +++ b/src/thumbnails.js @@ -107,8 +107,9 @@ async function generateThumbnail(type, file) { let buffer; try { + const quality = getConfigValue('thumbnailsQuality', 95); const image = await jimp.read(pathToOriginalFile); - buffer = await image.cover(mySize[0], mySize[1]).quality(95).getBufferAsync('image/jpeg'); + buffer = await image.cover(mySize[0], mySize[1]).quality(quality).getBufferAsync('image/jpeg'); } catch (inner) { console.warn(`Thumbnailer can not process the image: ${pathToOriginalFile}. Using original size`);