for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of Cecil.
*
* Copyright (c) Arnaud Ligny <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cecil\Step\Optimize;
use Cecil\Assets\Image\Optimizer;
/**
* Optimize image files.
class Images extends AbstractOptimize
{
* {@inheritdoc}
public function getName(): string
return 'Optimizing images';
}
public function init(array $options): void
$this->type = 'images';
parent::init($options);
public function setProcessor(): void
$this->processor = Optimizer::create($this->config->get('assets.images.quality') ?? 75);
public function processFile(\Symfony\Component\Finder\SplFileInfo $file): string
try {
$this->processor->optimize($file->getPathname());
} catch (\Exception $e) {
$this->builder->getLogger()->error(sprintf('Can\'t optimize image "%s": "%s"', $file->getPathname(), $e->getMessage()));
return $file->getContents();
public function encode(string $content = null): ?string
return base64_encode((string) $content);
public function decode(string $content = null): ?string
return base64_decode((string) $content);