oc-resizer-plugin/compressors/JpgCompressor.php

26 lines
605 B
PHP
Raw Normal View History

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