Skip to content

Instantly share code, notes, and snippets.

@aktaumag
Last active August 25, 2018 14:14
Show Gist options
  • Save aktaumag/d4ecbf53d3b9de0f335c2e7a7d549583 to your computer and use it in GitHub Desktop.
Save aktaumag/d4ecbf53d3b9de0f335c2e7a7d549583 to your computer and use it in GitHub Desktop.
/*
Оптимизация автогенерирующихся картинок
*/
imagejpeg($this->image, $file, $quality);
// WebSEO.kz START add: После сохранения превьюшки в формате jpg/jpeg, оптимизируем файл классом Imagick
// Create new imagick object
$im = new Imagick($file);
// Optimize the image layers
$im->optimizeImageLayers();
// Compression and quality
$im->setImageCompression(Imagick::COMPRESSION_JPEG);
$im->setImageCompressionQuality(50);
// Write the image back
$im->writeImages($file, true);
// WS WebSEO END
// WebSEO.kz edit: При сохранении превьюшки в формате png, можно сразу оптимизировать указав сжалие и отключение фильтров
// imagepng($this->image, $file);
imagepng($this->image, $file, 5, PNG_NO_FILTER );
@aktaumag
Copy link
Author

// imagejpeg($image); // WebSEO.kz Michael Nossov меняю вывод картинки, чтобы выводить оптимизированное изображение
imagepng($image, null, 5, PNG_NO_FILTER );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment