我使用Intervention Image上传单个图像的两个版本(大小),以显示在不同的页面上。
用户始终上传1000 x 1000像素的图像,原始图像用于单个产品的产品页面,较小的图像用于“所有产品”页面。
除了缩小的图像质量很差以外,这都可以正常工作。像素化了。
我正在使用Laravel 4.2。我的php版本是5.5.11。我正在本地主机上使用Xampp进行开发。我已经看过这个问题,而且我很确定GD已安装。
是因为GD不如imagick好吗?因为我似乎一辈子都无法安装那东西...
编辑:这就是问题!我终于设法使imagick正常工作并将其更改为驱动程序。高质量的图像。
这是我的路线,尽管我不认为这是问题所在:
$file = Input::file('photo');
$fileName = Input::get('name').'.'.$file->getClientOriginalExtension();
$fileName= str_replace(' ', '_', $fileName);
$destinationPath = 'productphotos/';
// upload new image
Image::make($file->getRealPath())
// original
->save($destinationPath.$fileName)
// resize
->resize(300, 300) // set true if you want proportional image resize
->save($destinationPath.'resize'.$fileName, 100);
$aDetails = Input::all();
$aDetails["photo"] = $fileName;
$aDetails["smallphoto"] = 'resize'.$fileName;
Product::create($aDetails);
return Redirect::to("products/".Input::get("product_id"));
您可以看到原始测试(原始尺寸1000x1000)和testresize(300x300)之间的差异。它们都以218x218显示。
我终于设法使imagick正常工作并将其更改为驱动程序。高质量的图像。GD驱动程序是问题所在,解决方案是改为imagick驱动程序。干杯!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句