oc-resizer-plugin/compressors/PngCompressor.php

26 lines
560 B
PHP
Raw Normal View History

2021-09-14 02:13:29 +02:00
<?php
namespace Aweos\Resizer\Compressors;
class PngCompressor extends Compressor {
public function make(string $path): array
{
$output = "/tmp/".str_slug(microtime());
$mimetype = mime_content_type($path);
system('imagemin '.escapeshellarg($path).' --plugin=pngquant > '.escapeshellarg($output));
system("mv ".escapeshellarg($output)." ".escapeshellarg($path));
return [
$path => [$path],
];
}
public function shouldGenerateVersions(): bool
{
return true;
}
}