Optimize your image for a better web

Questo articolo รจ stato scritto oltre 1 years, il contenuto potrebbe essere datato.

Web is cool. Web have images. Many images. Many huge images!

Trimage is a simple gui (available on Linux) solution to optimize the images (use different tools for PNG and JPG) but with an huge number of image don’t work very well (I talk about other than 400).

After a search on internet I’ve founded image_optim, a powerful ruby software, that supports many tools and work from CLI.

This software is better respect to trimage because have no problem with many images and with a little script we can use in recursive for scan automatically the sub folder:

#!/bin/bash
shopt -s globstar nullglob
basename=$PWD
for dir in ./**/;do
cd "$basename/$dir"
echo Optimization on $dir
image_optim -r *.{jpg,png,gif,jpeg}
done

As we can see, with bash we get the current working directory in the shell and with a simple loop we execute image_optim in every folder.

Also image_optim search only for the specified format!

I suggest to you to try it and check the softwares supported on your system, in my case on Debian svgo and pngout are not available in the repository but this tool have a powerful config file for enable the tools and force default values.

Liked it? Take a second to support Mte90 on Patreon!
Become a patron at Patreon!

Leave a Reply

Your email address will not be published. Required fields are marked *