Skip to content

Commit

Permalink
chore(deps): migrate to image-type 5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eliandoran committed Dec 10, 2024
1 parent d6b2fc8 commit e0e98e2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/services/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 || {
Expand All @@ -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
}
}

Expand Down

0 comments on commit e0e98e2

Please sign in to comment.