From 24c53106bd62812a1e9f0478d86372537aa7aec6 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sat, 10 Sep 2022 19:59:08 +0200 Subject: [PATCH] Dont update png files --- compressors/PngCompressor.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/compressors/PngCompressor.php b/compressors/PngCompressor.php index a401064..d2884f8 100644 --- a/compressors/PngCompressor.php +++ b/compressors/PngCompressor.php @@ -6,8 +6,8 @@ use Illuminate\Support\Collection; use Intervention\Image\ImageManager; use Storage; -class PngCompressor extends Compressor { - +class PngCompressor extends Compressor +{ protected function getExtension(): string { return 'png'; @@ -24,7 +24,7 @@ class PngCompressor extends Compressor { $mimetype = mime_content_type($path); system('imagemin '.escapeshellarg($path).' --plugin=pngquant > '.escapeshellarg($output)); - system("mv ".escapeshellarg($output)." ".escapeshellarg($path)); + system('mv '.escapeshellarg($output).' '.escapeshellarg($path)); return [ $path => [$path], @@ -43,12 +43,10 @@ class PngCompressor extends Compressor { public function start(): void { - // } public function end(): void { - // } public function resize(Collection $size, bool $update, callable $callback): void @@ -65,8 +63,11 @@ class PngCompressor extends Compressor { $versionFilename = $this->media->versionsDirPath().'/'.$this->versionFilename($destWidth, $destHeight); + if ($update && Storage::exists($versionFilename)) { + return; + } + $this->moveTo($temp, $versionFilename); call_user_func($callback, $this->media, Storage::path($versionFilename)); } - }