我使用这个包started/installation来压缩上传到服务器上的图像。然而,图像并没有被压缩。
发布于 2018-05-20 07:01:58
很简单:
只有在编码JPG格式时才会应用质量,因为PNG压缩是无损的,不会影响图像质量。默认: 90。
如果希望此库压缩图像,请使用jpg。
发布于 2018-12-11 18:49:04
看起来你只是在保存原始图像,而不是调整大小的版本。你可以试试这样的方法:
public function store()
{
// Get image
$img = request()->file('img');
// Minify image
$resizedImage = Image::make($img)->encode('jpg', 1); // put this in a variable
// use a unique filename
$filename = $img->hashName()
// Store image in uploads folder
Storage::disk('public')->put('uploads/'.$filename, $resizedImage->__toString());
}https://stackoverflow.com/questions/50432345
复制相似问题