diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2022-12-08 14:49:49 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-08 14:49:49 +0900 |
| commit | e81c2962a0b04e38a4c974e50d2cd6bc495cbdf2 (patch) | |
| tree | 1a9b54a00de1e769620d547f77a000b442839d12 /packages/backend/src/core/DriveService.ts | |
| parent | 12.120.0-alpha.11 (diff) | |
| download | sharkey-e81c2962a0b04e38a4c974e50d2cd6bc495cbdf2.tar.gz sharkey-e81c2962a0b04e38a4c974e50d2cd6bc495cbdf2.tar.bz2 sharkey-e81c2962a0b04e38a4c974e50d2cd6bc495cbdf2.zip | |
enhance: AVIF support (#9281)
* chore: Make image/avif browsersafe
* server side
* change FileInfoService
* :v:
* avifはMastodonでは絶望的 see https://github.com/misskey-dev/misskey/issues/9283
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
Diffstat (limited to 'packages/backend/src/core/DriveService.ts')
| -rw-r--r-- | packages/backend/src/core/DriveService.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index 895073c32c..bbdb5fae83 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -138,6 +138,7 @@ export class DriveService { if (type === 'image/jpeg') ext = '.jpg'; if (type === 'image/png') ext = '.png'; if (type === 'image/webp') ext = '.webp'; + if (type === 'image/avif') ext = '.avif'; if (type === 'image/apng') ext = '.apng'; if (type === 'image/vnd.mozilla.apng') ext = '.apng'; } @@ -262,7 +263,7 @@ export class DriveService { } } - if (!['image/jpeg', 'image/png', 'image/webp', 'image/svg+xml'].includes(type)) { + if (!['image/jpeg', 'image/png', 'image/webp', 'image/avif', 'image/svg+xml'].includes(type)) { this.registerLogger.debug('web image and thumbnail not created (not an required file)'); return { webpublic: null, @@ -287,7 +288,7 @@ export class DriveService { } satisfyWebpublic = !!( - type !== 'image/svg+xml' && type !== 'image/webp' && + type !== 'image/svg+xml' && type !== 'image/webp' && type !== 'image/avif' && !(metadata.exif ?? metadata.iptc ?? metadata.xmp ?? metadata.tifftagPhotoshop) && metadata.width && metadata.width <= 2048 && metadata.height && metadata.height <= 2048 @@ -307,7 +308,7 @@ export class DriveService { this.registerLogger.info('creating web image'); try { - if (['image/jpeg', 'image/webp'].includes(type)) { + if (['image/jpeg', 'image/webp', 'image/avif'].includes(type)) { webpublic = await this.imageProcessingService.convertSharpToJpeg(img, 2048, 2048); } else if (['image/png'].includes(type)) { webpublic = await this.imageProcessingService.convertSharpToPng(img, 2048, 2048); @@ -329,7 +330,7 @@ export class DriveService { let thumbnail: IImage | null = null; try { - if (['image/jpeg', 'image/webp', 'image/png', 'image/svg+xml'].includes(type)) { + if (['image/jpeg', 'image/webp', 'image/avif', 'image/png', 'image/svg+xml'].includes(type)) { thumbnail = await this.imageProcessingService.convertSharpToWebp(img, 498, 280); } else { this.registerLogger.debug('thumbnail not created (not an required file)'); |