explicitly use webp

This commit is contained in:
2023-04-26 20:58:39 +10:00
parent 3cbce25394
commit 4a83c7e171
3 changed files with 4 additions and 61 deletions

View File

@@ -118,7 +118,6 @@ class StoreUploadedFileJob implements ShouldQueue
$variants = [];
$originalImage = Image::make($this->uploadedFilePath);
$optimizerChain = OptimizerChainFactory::create();
$dimensions = [$originalImage->getWidth(), $originalImage->getHeight()];
$this->media->dimensions = implode('x', $dimensions);
@@ -151,8 +150,7 @@ class StoreUploadedFileJob implements ShouldQueue
// Optimize and store image
$tempImagePath = tempnam(sys_get_temp_dir(), 'optimize');
$image->save($tempImagePath);
$optimizerChain->optimize($tempImagePath);
$image->encode('webp', 75)->save($tempImagePath);
Storage::disk($storageDisk)->putFileAs('/', new SplFileInfo($tempImagePath), $newFilename);
unlink($tempImagePath);
}//end if
@@ -168,6 +166,7 @@ class StoreUploadedFileJob implements ShouldQueue
}
}
$this->media->mime_type = 'image/webp';
$this->media->variants = $variants;
}//end if