From e0e98e229ea39d8a167a378d23e35ad47faeb203 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 10 Dec 2024 23:21:32 +0200 Subject: [PATCH] chore(deps): migrate to image-type 5.2.0 --- src/services/image.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/image.ts b/src/services/image.ts index 3ee136f32..dca97c48a 100644 --- a/src/services/image.ts +++ b/src/services/image.ts @@ -15,7 +15,7 @@ import htmlSanitizer from "./html_sanitizer.js"; async function processImage(uploadBuffer: Buffer, originalName: string, shrinkImageSwitch: boolean) { const compressImages = optionService.getOptionBool("compressImages"); - const origImageFormat = getImageType(uploadBuffer); + const origImageFormat = await getImageType(uploadBuffer); if (!origImageFormat || !["jpg", "png"].includes(origImageFormat.ext)) { shrinkImageSwitch = false; @@ -30,7 +30,7 @@ async function processImage(uploadBuffer: Buffer, originalName: string, shrinkIm if (compressImages && shrinkImageSwitch) { finalImageBuffer = await shrinkImage(uploadBuffer, originalName); - imageFormat = getImageType(finalImageBuffer); + imageFormat = await getImageType(finalImageBuffer); } else { finalImageBuffer = uploadBuffer; imageFormat = origImageFormat || { @@ -44,12 +44,12 @@ async function processImage(uploadBuffer: Buffer, originalName: string, shrinkIm }; } -function getImageType(buffer: Buffer) { +async function getImageType(buffer: Buffer) { if (isSvg(buffer.toString())) { return { ext: 'svg' } } else { - return imageType(buffer) || { ext: "jpg" }; // optimistic JPG default + return await imageType(buffer) || { ext: "jpg" }; // optimistic JPG default } }