From 4ddef4e11997d197b72b7d557b631694ec1f521a Mon Sep 17 00:00:00 2001 From: Novout Date: Fri, 31 Mar 2023 17:52:48 -0300 Subject: [PATCH] fix(image): ignore compressor in gif mimetype --- packages/better-write-image-converter/src/index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/better-write-image-converter/src/index.ts b/packages/better-write-image-converter/src/index.ts index ec08806b6..52747c2bc 100644 --- a/packages/better-write-image-converter/src/index.ts +++ b/packages/better-write-image-converter/src/index.ts @@ -107,11 +107,17 @@ export const getImageFileRaw = ( _.type = 'file' _.accept = options?.accept || '.png, .svg, .jpg, .jpeg' _.addEventListener('change', async function () { - const file = (this.files as any)[0] + const files = this.files - if (!file) return + if (!files || files.length === 0) { + rej() + + return + } + + const file = files[0] - if (options?.compress?.value) { + if (options?.compress?.value && file.type !== 'image/gif') { new Compressor(file, { quality: options?.compress?.quality ?? 1.0, async success(compressed) {