Imagemin
An alternative would be imagemin , via the terminal using imagemin-cli or if you prefer via imagein-app application, but the latter does not work as well (by the trial version). There is also the possibility via Grunt or Gulp .
In case you use via terminal imagemin-cli
:
# instalar o imagemin via npm
npm install -g imagemin-cli
# optimizar todas as imagens JPG/PNG/SVG de uma pasta
imagemin pasta_com_images/* -o pasta_de_destino/
Using the reference images (see below) for comparison it is verified that:
-
c-1920.jpg
had a 6.7% reduction
-
pia01969-saturn-voyager1.png
had a reduction of 11.8%
ImageOptim
Another alternative for bitmap images would be ImageOptim , via the terminal using Imageoptim-cli or if you prefer via imageoptim for MAC OS , or for other platforms . There is also the possibility via Grunt or Gulp .
In case you use via terminal imageoptim-cli
:
# instalar via npm
npm install -g imageoptim-cli
# optimizar todas as imagens JPG/PNG de uma pasta
imageoptim -d ./pasta_com_images/
Using the reference images for comparison it is verified that:
-
c-1920.jpg
had a reduction of 21.1%
-
pia01969-saturn-voyager1.png
had a reduction of 10.7%
Summary
For this small experience, ImageOptim considerably reduced the JPEG image more than Imagenin (21.1% instead of 6.7%). The PNG image was close, obtaining the best image reduction (11.8% instead of the 10.7% of ImageOptim). On the other hand, imagemin also optimizes SVG images.
For the comparison, we used the source images JPG and PNG used in the Lacobus response .
For other examples see the following comparison
Hope you can help someone!