bulk image compress - nodejs
const fs = require("fs"); const path = require("path"); const sharp = require("sharp"); // ============================================================ // BULK IMAGE COMPRESSOR // Node.js + Sharp + libvips // ============================================================ const SOURCE_DIR = path.join(__dirname, "creek-bay"); const TARGET_DIR = path.join(__dirname, "creek-bay-compress"); // ------------------------------------------------------------ // COMPRESSION QUALITY // // 1 = maximum compression / lowest quality // 100 = highest quality / lowest compression // // Recommended starting values: // // JPEG : 60 - 80 // WebP : 60 - 80 // AVIF : 40 - 70 // // ------------------------------------------------------------ const COMPRESSION_QUALITY = 60; // ------------------------------------------------------------ // OUTPUT FORMAT // // null = KEEP ORIGINAL FORMAT // // "webp" = Convert all compatible images to WebP //...