Advanced image optimization and compression on web servers without using external services

Asked

Viewed 532 times

6

How to do even more optimized compression than you can achieve with tools like ImageMagick and libgd (GD) without generating WEBP image?

Some services such as https://tinypng.com/ and http://www.jpegmini.com/ 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 am using PHP 5.5 and have root access, but any tool that is compatible with *Nix and can be executed by command line, without requiring access to external web service, is welcome.

  • 3

    If you pay attention to the tinypng page, they talk about "lossy Compression" - they lose quality yes, although the service is designed to cause a loss imperceptible quality. What tinypng does are exactly these most complex optimizations that you’re thinking of.

  • 1

    There is also the pngcrush png. What image formats? PNG and JPEG?

  • 2

    Take a look at this link https://pngquant.org/ Tinypng uses this library if using it directly on the server will not use the external server.

  • The two of you who commented: if you can give an answer more canonical, and relatively documented, even if the suggested app suggestion has been given by others, I approve the best answer, not the first answer.

2 answers

4


Dude,

doing a search I found an answer in gringo stack. I think it can help you:

  • pngcrush
  • jpegtran

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

4

beauty?

If what you need is to compress images for optimal use on the web, I recommend reading this article which i had satisfactory results.

https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/image-optimization

Based on the fact that you have no restrictions on installing anything on the server, within this article there is a section: "Tools and Parameter tuning", where there are the best compression tools for each image extension.

Tools and Parameter tuning

There is no one Perfect image format, tool, or a 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.

Don’t 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 don’t assume that all images must be Compressed with the same Settings.

I hope I’ve tried

  • 1

    Jefferson, in the OS links to external resources can be lost. It is better that the response has in its own body the answer.

  • Oops, I’ll edit the answer. Abcs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.