diff --git a/packages/backend/src/server/file/send-drive-file.ts b/packages/backend/src/server/file/send-drive-file.ts index 967df1d57..cefd13a51 100644 --- a/packages/backend/src/server/file/send-drive-file.ts +++ b/packages/backend/src/server/file/send-drive-file.ts @@ -11,7 +11,7 @@ import { DriveFiles } from '@/models/index'; import { InternalStorage } from '@/services/drive/internal-storage'; import { downloadUrl } from '@/misc/download-url'; import { detectType } from '@/misc/get-file-info'; -import { convertToJpeg, convertToPng } from '@/services/drive/image-processor'; +import { convertToWebp, convertToPng } from '@/services/drive/image-processor'; import { GenerateVideoThumbnail } from '@/services/drive/generate-video-thumbnail'; import { StatusError } from '@/misc/fetch'; import { FILE_TYPE_BROWSERSAFE } from '@/const'; @@ -65,10 +65,8 @@ export default async function(ctx: Koa.Context) { const convertFile = async () => { if (isThumbnail) { - if (['image/jpeg', 'image/webp'].includes(mime)) { - return await convertToJpeg(path, 498, 280); - } else if (['image/png', 'image/svg+xml'].includes(mime)) { - return await convertToPng(path, 498, 280); + if (['image/jpeg', 'image/webp', 'image/png', 'image/svg+xml'].includes(mime)) { + return await convertToWebp(path, 498, 280); } else if (mime.startsWith('video/')) { return await GenerateVideoThumbnail(path); } diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index 0135ca107..04e9c8dbc 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -194,6 +194,7 @@ export async function generateAlts(path: string, type: string, generateWeb: bool } satisfyWebpublic = !!( + type !== 'image/svg+xml' && !(metadata.exif || metadata.iptc || metadata.xmp || metadata.tifftagPhotoshop) && metadata.width && metadata.width <= 2048 && metadata.height && metadata.height <= 2048 diff --git a/packages/client/src/scripts/upload.ts b/packages/client/src/scripts/upload.ts index 06d4e9ddd..af0de3878 100644 --- a/packages/client/src/scripts/upload.ts +++ b/packages/client/src/scripts/upload.ts @@ -16,10 +16,10 @@ export const uploads = ref([]); const compressTypeMap = new Map([ // [圧縮前の形式, 圧縮後の形式], - ['image/jpeg', 'image/jpeg'], - ['image/webp', 'image/jpeg'], - ['image/png', 'image/png'], - ['image/svg', 'image/png'], + ['image/jpeg', 'image/webp'], + ['image/webp', 'image/webp'], + ['image/png', 'image/webp'], + ['image/svg', 'image/webp'], ]); export function uploadFile(file: File, folder?: any, name?: string, keepOriginal: boolean = defaultStore.state.keepOriginalUploading): Promise {