diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2023-03-11 14:11:40 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-11 14:11:40 +0900 |
| commit | 88e3d3e8cbe26c0280308e819965a64a91491f90 (patch) | |
| tree | 25c9039f6fa6725af4fa5a7de5decb71f2a3150b /packages/backend/src/server/FileServerService.ts | |
| parent | Update CHANGELOG.md (diff) | |
| download | sharkey-88e3d3e8cbe26c0280308e819965a64a91491f90.tar.gz sharkey-88e3d3e8cbe26c0280308e819965a64a91491f90.tar.bz2 sharkey-88e3d3e8cbe26c0280308e819965a64a91491f90.zip | |
enhance(server): 画像圧縮周り(主にサムネイルの仕様)の変更 (#10287)
* DriveService, is-mime-image
* static, previewをavifに, アニメーション画像でもthumbnailを生成
* fallback
* animated: true
* fix
* avatarはwebp
* revert ?? file.url
---------
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
Diffstat (limited to 'packages/backend/src/server/FileServerService.ts')
| -rw-r--r-- | packages/backend/src/server/FileServerService.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts index 6db9a9672c..fb1c67f20d 100644 --- a/packages/backend/src/server/FileServerService.ts +++ b/packages/backend/src/server/FileServerService.ts @@ -130,7 +130,7 @@ export class FileServerService { if (isMimeImage(file.mime, 'sharp-convertible-image-with-bmp')) { reply.header('Cache-Control', 'max-age=31536000, immutable'); - const url = new URL(`${this.config.mediaProxy}/static.webp`); + const url = new URL(`${this.config.mediaProxy}/static.avif`); url.searchParams.set('url', file.url); url.searchParams.set('static', '1'); @@ -151,7 +151,7 @@ export class FileServerService { if (['image/svg+xml'].includes(file.mime)) { reply.header('Cache-Control', 'max-age=31536000, immutable'); - const url = new URL(`${this.config.mediaProxy}/svg.webp`); + const url = new URL(`${this.config.mediaProxy}/svg.avif`); url.searchParams.set('url', file.url); file.cleanup(); @@ -291,9 +291,9 @@ export class FileServerService { }; } } else if ('static' in request.query) { - image = this.imageProcessingService.convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 498, 280); + image = this.imageProcessingService.convertSharpToAvifStream(await sharpBmp(file.path, file.mime), 498, 422); } else if ('preview' in request.query) { - image = this.imageProcessingService.convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 200, 200); + image = this.imageProcessingService.convertSharpToAvifStream(await sharpBmp(file.path, file.mime), 200, 200); } else if ('badge' in request.query) { const mask = (await sharpBmp(file.path, file.mime)) .resize(96, 96, { @@ -325,7 +325,7 @@ export class FileServerService { type: 'image/png', }; } else if (file.mime === 'image/svg+xml') { - image = this.imageProcessingService.convertToWebpStream(file.path, 2048, 2048); + image = this.imageProcessingService.convertToAvifStream(file.path, 2048, 2048); } else if (!file.mime.startsWith('image/') || !FILE_TYPE_BROWSERSAFE.includes(file.mime)) { throw new StatusError('Rejected type', 403, 'Rejected type'); } |