diff options
| author | Kagami Sascha Rosylight <saschanaz@outlook.com> | 2023-03-10 01:37:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-10 09:37:22 +0900 |
| commit | 3f53cbd8f680c5659c53bf709fdd044c5dcb59c7 (patch) | |
| tree | b017dd7c0af0862df4e1778a87ad703bf8526e5d /packages/backend/src/core/DriveService.ts | |
| parent | enhance(backend): restore OpenAPI endpoints (#10281) (diff) | |
| download | sharkey-3f53cbd8f680c5659c53bf709fdd044c5dcb59c7.tar.gz sharkey-3f53cbd8f680c5659c53bf709fdd044c5dcb59c7.tar.bz2 sharkey-3f53cbd8f680c5659c53bf709fdd044c5dcb59c7.zip | |
fix(backend/DriveService): convert WebP/AVIF to WebP (#10239)
* fix(backend/DriveService): convert transparent WebP/AVIF to PNG
* webpにする
その希望が複数ありましたので
* Update packages/backend/src/core/DriveService.ts
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
* update test
* webpはwebpublicにできる
---------
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
Diffstat (limited to 'packages/backend/src/core/DriveService.ts')
| -rw-r--r-- | packages/backend/src/core/DriveService.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index f4a06faebb..c3835faa33 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -299,7 +299,7 @@ export class DriveService { } satisfyWebpublic = !!( - type !== 'image/svg+xml' && type !== 'image/webp' && type !== 'image/avif' && + type !== 'image/svg+xml' && type !== 'image/avif' && !(metadata.exif ?? metadata.iptc ?? metadata.xmp ?? metadata.tifftagPhotoshop) && metadata.width && metadata.width <= 2048 && metadata.height && metadata.height <= 2048 @@ -319,11 +319,11 @@ export class DriveService { this.registerLogger.info('creating web image'); try { - if (['image/jpeg', 'image/webp', 'image/avif'].includes(type)) { + if (type === 'image/jpeg') { webpublic = await this.imageProcessingService.convertSharpToJpeg(img, 2048, 2048); - } else if (['image/png'].includes(type)) { - webpublic = await this.imageProcessingService.convertSharpToPng(img, 2048, 2048); - } else if (['image/svg+xml'].includes(type)) { + } else if (['image/webp', 'image/avif'].includes(type)) { + webpublic = await this.imageProcessingService.convertSharpToWebp(img, 2048, 2048); + } else if (['image/png', 'image/svg+xml'].includes(type)) { webpublic = await this.imageProcessingService.convertSharpToPng(img, 2048, 2048); } else { this.registerLogger.debug('web image not created (not an required image)'); @@ -749,7 +749,7 @@ export class DriveService { }: UploadFromUrlArgs): Promise<DriveFile> { // Create temp file const [path, cleanup] = await createTemp(); - + try { // write content at URL to temp file const { filename: name } = await this.downloadService.downloadUrl(url, path); |