mirror of
https://github.com/misskey-dev/media-proxy.git
synced 2025-08-03 23:06:36 +09:00
add avatar mode
This commit is contained in:
21
src/index.ts
21
src/index.ts
@ -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',
|
||||
|
Reference in New Issue
Block a user