Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image Laravel图像干涉调整质量损失_Image_Laravel_Image Resizing_Intervention - Fatal编程技术网

Image Laravel图像干涉调整质量损失

Image Laravel图像干涉调整质量损失,image,laravel,image-resizing,intervention,Image,Laravel,Image Resizing,Intervention,在我的Laravel web应用程序中,我使用了。我正在保存上传图像的三个版本:'original','500_auto'和一个自定义大小的图像 $image=image::make(输入::文件('file'); //保存原始图像 $image->save($folder.'original..$extension); //保存500_自动图像 $image->resize(500,null,函数($constraint){ $constraint->aspectRatio(); }); $i

在我的Laravel web应用程序中,我使用了。我正在保存上传图像的三个版本:
'original'
'500_auto'
和一个自定义大小的图像

$image=image::make(输入::文件('file');
//保存原始图像
$image->save($folder.'original..$extension);
//保存500_自动图像
$image->resize(500,null,函数($constraint){
$constraint->aspectRatio();
});
$image->save($folder.'500_auto..$extension,100);
//检查是否设置了大小
if(isset($config->images->width)和&isset($config->images->height)){
//赋值
$width=$config->images->width;
$height=$config->images->height;
//创建自定义拇指
$image->resize($width,$height,function,$constraint){
$constraint->aspectRatio();
});
$image->save($folder.$width.'.$height.'.$extension,100);
}
干预驱动程序在配置中设置为
'gd'

'driver' => 'gd'
这是我正在上传的图像:

这是自定义拇指的结果,其配置设置与原始尺寸(1800 x 586)完全一致:


正如您看到的第二幅图像,调整大小后的图像质量损失很大。我如何修复此问题?

您首先将图像调整为小格式,然后拍摄小图像并将其重新调整为原始大小。如果您颠倒顺序,则改为从原始大小->原始大小->小大小

就我个人而言,我通常更喜欢为每个新映像重新调用
Image::make()
,只是为了确保我不会在过程中搞砸类似的事情。

您可以使用“backup()”方法保存对象的状态,使用“reset()”方法返回备份状态:

// create an image
$img = Image::make('public/foo.jpg');

// backup status
$img->backup();

// perform some modifications
$img->resize(320, 240);
$img->invert();
$img->save('public/small.jpg');

// reset image (return to backup state)
$img->reset();

// perform other modifications
$img->resize(640, 480);
$img->invert();
$img->save('public/large.jpg');
有关此页面的详细信息:

谢谢你的帮助。非常合理,它正在调整到小版本,然后再调整到1800x586。正如你提到的,每次调整大小之前,我都会调用Image::make()来更新该方法。创建新的
Image::make()很好
用于每次调整大小。这就是在调整大小功能中导致图像模糊的原因。