4 Commits

Author SHA1 Message Date
384c51569f update SPECIFICATION.md 2023-03-17 15:51:04 +00:00
57aa87f370 0.0.19 2023-03-17 15:50:07 +00:00
d86823e32d 0.0.18 2023-03-17 13:44:13 +00:00
405e6a5adb quality, effort変更 2023-03-17 13:43:45 +00:00
6 changed files with 8 additions and 6 deletions

View File

@ -72,7 +72,7 @@ https://www.google.com/images/errors/robot.png をプロキシする場合:
#### static
存在すると、アニメーション画像では最初のフレームのみの静止画のwebpが応答される。
emojiまたはavatarとstaticが同時に指定された場合は、それぞれに応じた高さが、指定されていない場合は幅498px・高さ280pxに収まるサイズ以下に縮小される。
emojiまたはavatarとstaticが同時に指定された場合は、それぞれに応じた高さが、指定されていない場合は幅498px・高さ422pxに収まるサイズ以下に縮小される。
#### preview
存在すると、幅200px・高さ200pxに収まるサイズ以下のwebpが応答される。

View File

@ -1,11 +1,12 @@
import sharp from 'sharp';
export const webpDefault = {
quality: 85,
quality: 77,
alphaQuality: 95,
lossless: false,
nearLossless: false,
smartSubsample: true,
mixed: true,
effort: 2,
};
export function convertToWebpStream(path, width, height, options = webpDefault) {
return convertSharpToWebpStream(sharp(path), width, height, options);

View File

@ -122,7 +122,7 @@ async function proxyHandler(request, reply) {
}
}
else if ('static' in request.query) {
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 498, 280);
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 498, 422);
}
else if ('preview' in request.query) {
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 200, 200);

View File

@ -1,6 +1,6 @@
{
"name": "misskey-media-proxy",
"version": "0.0.17",
"version": "0.0.19",
"description": "The Media Proxy for Misskey",
"main": "built/index.js",
"packageManager": "pnpm@7.28.0",

View File

@ -16,12 +16,13 @@ export type IImageStream = {
export type IImageStreamable = IImage | IImageStream;
export const webpDefault: sharp.WebpOptions = {
quality: 85,
quality: 77,
alphaQuality: 95,
lossless: false,
nearLossless: false,
smartSubsample: true,
mixed: true,
effort: 2,
};
export function convertToWebpStream(path: string, width: number, height: number, options: sharp.WebpOptions = webpDefault): IImageStream {

View File

@ -168,7 +168,7 @@ async function proxyHandler(request: FastifyRequest<{ Params: { url: string; };
};
}
} else if ('static' in request.query) {
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 498, 280);
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 498, 422);
} else if ('preview' in request.query) {
image = convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 200, 200);
} else if ('badge' in request.query) {