Optimization and advanced compression of images on web servers without the use of external services


How to make compression even more optimized than can be achieved with tools such as ImageMagick and libgd (GD) without generating WEBP image?

Some services, such as link and link promise to optimize image without loss of quality. I also know that there are other tools that make more complex optimizations that take into account limitations in human vision.

I'm using PHP 5.5 and I have root access, however any tool that is compatible with * nix and can be run by command line, without requiring access to external web service, is welcome.

asked by anonymous 05.06.2015 / 06:07

2 answers



Doing a search found an answer in the gringo stack. I think it might help you:

  • pngcrush
  • jpegtran

With the option pngcrush -brute I achieved a reduction of ~ 20% in .png and with jpegtran I got 10% in .jpg .

18.06.2015 / 16:51


If you need to compress images for optimum use on the web, I recommend reading this article which I have had satisfactory results.


Based on the fact that you have no restrictions on installing anything on the server, there is a section called "Tools and parameter tuning", where the best compression tools exist for each image extension. >


Tools and parameter tuning


There is no one perfect image, tool, or set of optimization   parameters that apply to all images. For best results you will have to   pick the format and its settings depending on the contents of the   image, and its visual and other technical requirements.

  • gifsicle - Create and optimize gif images - link
  • jpegtran - Optimizes JPEG images - link
  • optipng - Optimizes PNG (lossless) - link
  • pngquant - Optimizes PNG (lossy) - link

Do not be afraid to experiment with parameters of each compressor. Dial   down the quality, see how it looks, then rinse, lather and repeat.   Once you've found a good set of settings, you can apply them to other   similar images on your site, but do not assume that all images must be   compressed with the same settings.

I hope to be happy

18.06.2015 / 21:40