node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey ยป



Minify a folder of images recursively while preserving folder structure.


First, make sure you've installed Node.js and NPM. Then, open a terminal and run:

npm install -g imagemin-instant


Navigate to a folder with images in your terminal. If you want to minify all images in the current directory, simply run:


Note: The original HD images will be overridden!

If you want to preserve the original images, navigate to the parent directory and run imagemin again, but specify an input and an output directory this time:

imagemin --in=my-images --out=minified-images


--in=dir            // Specify an input directory.
--out=dir           // Specify an output directory.
--quality=50        // The quality of minified PNG files.