Answer the question
In order to leave comments, you need to log in
Are there ready-made solutions for lossless image compression?
It's no secret that this theme is gaining a lot of popularity due to the requirements of Google and the overall load of the site. Of course, some CMS or frameworks have some ready-made solutions.
Tell me there is one that is not optimized for a specific CMS on the OPP. Those. a function that scans a directory for images and compresses them, the only thing that needs to be done is to specify the path of the directory to it.
$path = "/images/";
function rszImage($path){
...
return ...;
}
Answer the question
In order to leave comments, you need to log in
Let's start with the fact that lossless image compression does not work for already compressed files, such as jpg, png, gif, with rare exceptions, when, for example, a gif or png has a smaller actual number of colors than specified in the palette. We are talking about lossy compression, which, although it does not spoil the image beyond recognition, still introduces serious distortions into the picture, both in terms of color, and in terms of "grain" and "artifacts". The acceptable level of compression is individual for each individual image, and is most often displayed on a conditional "quality" scale from 1 to 10 (sometimes from 1 to 100, it's just that the distortion step is smaller), where 10 is a very low compression ratio and high quality, and 1 - complete bullshit, in which it is not always possible to guess what the picture is about. Accordingly, compressing everything in a folder is not the best option, with each pass and compression, the quality drops, even though we set the maximum quality, after N iterations we will get pure bullshit. Therefore, Google determines the ratio of the image size in pixels to the size in bytes and gives recommendations based on statistics, how much such a picture should approximately weigh, +/- , to pinch or not. So I would not be right here all the pictures in the folder are so naively one size fits all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question