add avatar mode

This commit is contained in:
tamaina
2023-02-03 19:52:57 +00:00
parent af640ecb27
commit 7058a16206

View File

@ -87,6 +87,27 @@ async function proxyHandler(request: FastifyRequest<{ Params: { url: string; };
})
.webp(webpDefault);
image = {
data,
ext: 'webp',
type: 'image/webp',
};
}
} else if ('avatar' in request.query && isConvertibleImage) {
if (!isAnimationConvertibleImage && !('static' in request.query)) {
image = {
data: fs.createReadStream(file.path),
ext: file.ext,
type: file.mime,
};
} else {
const data = sharp(file.path, { animated: !('static' in request.query) })
.resize({
height: 320,
withoutEnlargement: true,
})
.webp(webpDefault);
image = {
data,
ext: 'webp',