From 3e9076045c5129deb8445ba9b48eba5f056a6ca3 Mon Sep 17 00:00:00 2001 From: chimiana Date: Sat, 17 Dec 2022 02:26:19 +0000 Subject: [PATCH] Fix for #9194, converts webp to png instead of jpg, preserving transparency --- packages/backend/src/services/drive/add-file.ts | 4 +++- packages/client/src/scripts/upload.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index a790fd5104..47b19e23ab 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -217,8 +217,10 @@ export async function generateAlts(path: string, type: string, generateWeb: bool logger.info('creating web image'); try { - if (['image/jpeg', 'image/webp'].includes(type)) { + if (['image/jpeg'].includes(type)) { webpublic = await convertSharpToJpeg(img, 2048, 2048); + } else if (['image/webp'].includes(type)) { + webpublic = await convertSharpToPng(img, 2048, 2048); } else if (['image/png'].includes(type)) { webpublic = await convertSharpToPng(img, 2048, 2048); } else if (['image/svg+xml'].includes(type)) { diff --git a/packages/client/src/scripts/upload.ts b/packages/client/src/scripts/upload.ts index 714c98d6a8..b1562f4a6a 100644 --- a/packages/client/src/scripts/upload.ts +++ b/packages/client/src/scripts/upload.ts @@ -18,7 +18,7 @@ export const uploads = ref([]); const compressTypeMap = { 'image/jpeg': { quality: 0.85, mimeType: 'image/jpeg' }, - 'image/webp': { quality: 0.85, mimeType: 'image/jpeg' }, + 'image/webp': { quality: 0.85, mimeType: 'image/png' }, 'image/svg+xml': { quality: 1, mimeType: 'image/png' }, } as const;