【发布时间】:2015-12-18 10:23:20
【问题描述】:
在我的 Laravel 网络应用程序中,我使用了Intervention Image library。我正在保存上传图片的三个版本:'original'、'500_auto' 和自定义尺寸图片。
$image = Image::make(Input::file('file');
// Save the orignal image
$image->save($folder . 'original.' . $extension);
// Save 500_auto image
$image->resize(500, null, function($constraint) {
$constraint->aspectRatio();
});
$image->save($folder . '500_auto.' . $extension, 100);
// Check if size is set
if (isset($config->images->width) && isset($config->images->height)) {
// Assign values
$width = $config->images->width;
$height = $config->images->height;
// Create the custom thumb
$image->resize($width, $height, function($constraint) {
$constraint->aspectRatio();
});
$image->save($folder . $width . '_' . $height . '.' . $extension, 100);
}
干预的驱动在配置中设置为'gd':
'driver' => 'gd'
这是我要上传的图片:original.jpg
这是自定义拇指的结果,其配置设置设置为与原始尺寸 (1800 x 586) 完全相同:1800_586.jpg
正如您看到的第二张图片,调整大小后的图片有很多质量损失。我该如何解决这个问题?
【问题讨论】:
标签: image laravel image-resizing intervention