add option in config.yaml to use png for avatar thumbs

This commit is contained in:
LenAnderson 2023-12-22 14:23:50 +00:00
parent 18445f527b
commit f862ffafd2
2 changed files with 5 additions and 1 deletions

View File

@ -25,6 +25,9 @@ autorun: true
disableThumbnails: false
# Thumbnail quality (0-100)
thumbnailsQuality: 95
# Generate avatar thumbnails as PNG instead of JPG (preserves transparency but increases filesize by about 100%)
# Changing this only affects new thumbnails. To recreate the old ones, clear out your ST/thumbnails/ folder.
avatarThumbnailsPng: false
# Allow secret keys exposure via API
allowKeysExposure: false
# Skip new default content checks

View File

@ -111,7 +111,8 @@ async function generateThumbnail(type, file) {
try {
const quality = getConfigValue('thumbnailsQuality', 95);
const image = await jimp.read(pathToOriginalFile);
buffer = await image.cover(mySize[0], mySize[1]).quality(quality).getBufferAsync('image/jpeg');
const imgType = type == 'avatar' && getConfigValue('avatarThumbnailsPng', false) ? 'image/png' : 'image/jpeg';
buffer = await image.cover(mySize[0], mySize[1]).quality(quality).getBufferAsync(imgType);
}
catch (inner) {
console.warn(`Thumbnailer can not process the image: ${pathToOriginalFile}. Using original size`);