What parameters can I add to Imagick
to improve image compression?
Even with this code, PageSpeed
Google continues to accuse images need to be reduced.
$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();