Don't crash the server on failed thumbnail generation

This commit is contained in:
SillyLossy
2023-04-11 19:42:54 +03:00
parent af114e5255
commit 8c8c2c40c4

View File

@@ -1887,8 +1887,13 @@ async function generateThumbnail(type, file) {
const imageSizes = { 'bg': [160, 90], 'avatar': [96, 144] };
const mySize = imageSizes[type];
try {
const image = await jimp.read(pathToOriginalFile);
await image.cover(mySize[0], mySize[1]).quality(95).writeAsync(pathToCachedFile);
}
catch {
return null;
}
return pathToCachedFile;
}