0
What parameters can I add to Imagick
to improve image compression?
Even with that code, PageSpeed
of Google continues to accuse that images need reduction.
$image = new \Imagick($request->img->path());
$image->setImageFormat('jpg');
$fileName = date('YmdHis') . microtime(true) . rand(111111111, 999999999) . '.' . $image->getImageFormat();
$image->setImageCompressionQuality(70);
$image->stripImage();
$image->setSamplingFactors(array('2x2', '1x1', '1x1'));
$image->setInterlaceScheme(\Imagick::INTERLACE_JPEG);
$image->setColorspace(\Imagick::COLORSPACE_SRGB);
$image->writeImage($path . '/' . $fileName);
$image->destroy();
But then you have to take into account if it is considering the actual compression or if the photo has been reduced with css or with attributes like width and height, making the original size unnecessary, which would be worth (measuring the cost benefit) generating a version with better size, summarizing "the problem may be partially in HTML". But I have no way of knowing without having details, especially the details reported by the pagespeed itself, because you may have misinterpreted what they say in the "log"
– Guilherme Nascimento
This is the result of pagespeed where it points out the problem: https://developers.google.com/speed/pagespeed/insights/? hl=en-br&url=https%3A%2F%2Fwww.infochat.com.br%2Fbusca%2Fporto-alegre%2Frs%2Ftodos%2Fjose
– Diego Vieira
Dear Diego, that’s exactly what I said, I formulated the answer.
– Guilherme Nascimento