【问题标题】:Intervention Image degrades quality of image on resize干预图像在调整大小时降低图像质量
【发布时间】:2015-03-28 04:51:51
【问题描述】:

我正在使用Intervention Image 上传单个图像的两个版本(小版和大版)以显示在不同的页面上。

用户总是上传 1000 x 1000 像素的图片,原图用于单个产品产品页面,较小的版本用于“所有产品”页面。

这很好用,只是缩小尺寸的图像质量很差。像素化了

我正在使用 Laravel 4.2。我的 php 版本是 5.5.11。我正在本地主机上使用 Xampp 进行开发。我查看了this question,我很确定 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"));

你可以看到stock test(原始尺寸1000x1000)和testresize(300x300)之间的区别。它们都以 218x218 显示。

【问题讨论】:

    标签: php image laravel-4 gd intervention


    【解决方案1】:

    我终于设法让 imagick 工作并将其更改为驱动程序。高质量的图像。 GD 驱动程序是问题所在,解决方案是更改为 imagick 驱动程序。 干杯!

    【讨论】:

    • 非常感谢。上传后有类似的白色背景不是白色的问题。更改为imagick,它解决了问题。 laravel 配置注意事项image.intervention.io/getting_started/installation 发布配置并在 config/image.php 中编辑
    • 我也遇到了同样的问题,但你的答案不清楚,你能帮忙解释一下你是如何解决这个问题的吗? @托马斯
    猜你喜欢
    • 1970-01-01
    • 2010-11-12
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 2011-01-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多