From 05382cf9e683e93d8194c53fa75a17fe8a9cc681 Mon Sep 17 00:00:00 2001 From: Victor Chanil Park Date: Mon, 18 Nov 2024 22:44:10 +0900 Subject: [PATCH] enhancement: image compression --- image-compression.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/image-compression.js b/image-compression.js index 8431d27..a35c27b 100644 --- a/image-compression.js +++ b/image-compression.js @@ -24,21 +24,18 @@ if (fs.existsSync(targetDir)) console.log(`Old directory removed: ${ targetDir }`); } -const allowedFormats = [".png", ".jpg", ".jpeg", ".webp"]; +const allowedFormats = [".png", ".jpg", ".jpeg", ".webp", ".tiff", ".bmp"]; async function convertAndCopyImage(imagePath, targetPath) { const ext = path.extname(imagePath).toLowerCase(); - if (ext === ".avif") + if (ext === ".avif" || ext === ".svg" || ext === ".gif" || ext === ".ico") { await fs.copy(imagePath, targetPath); console.log(`Copied: ${ targetPath }`); - } else if (ext === ".svg") - { - await fs.copy(imagePath, targetPath); - console.log(`Copied: ${ targetPath }`); - } else if (allowedFormats.includes(ext)) + } + else if (allowedFormats.includes(ext)) { await sharp(imagePath) .toFormat("avif", { quality: ExpectedQuality })