liip想象捆绑包创建所有相同文件大小的缩略图

时间:2016-04-20 19:37:57

标签: php symfony thumbnails liipimaginebundle

我们正在使用Symfony2和LiipImagineBundle来创建用户上传内容的缩略图。

每个缩略图都是161kb,无论它在图像中有多少或多少。

这是我的liip配置文件:

liip_imagine:
    resolvers:
        default:
            web_path: ~
    filter_sets:
        my_thumb:
            quality: 75
            filters:
                thumbnail: { size: [80, 80], mode: outbound }
        productvariant_preview:
            filters:
                resize: { size: [450, 450] }
        productvariant_thumb:
            filters:
                resize: { size: [292, 292] }
        productvariantdesign_thumb:
            filters:
                resize: { size: [231, 231] }
        profiledesign_thumb:
            filters:
                resize: { size: [200, 200] }
        asseenindesign_thumb:
            filters:
                resize: { size: [158, 158] }
        homepage_slider:
            filters:
                resize: { size: [922, 388] }
        homepage_featuredlink:
            filters:
                resize: { size: [450, 260] }
        homepage_secondaryfeaturedlink:
            filters:
                resize: { size: [294, 188] }
        homepage_productvariantdesign:
            filters:
                resize: { size: [223, 223] }
        printcolor_thumbnail:
            filters:
                resize: { size: [30, 30] }

调整过滤器大小:

namespace Imagine\Filter\Basic;

use Imagine\Filter\FilterInterface;
use Imagine\Image\ImageInterface;
use Imagine\Image\BoxInterface;

/**
 * A resize filter
 */
class Resize implements FilterInterface
{   
    /**
     * @var BoxInterface
     */
private $size;
private $filter;

/**
 * Constructs Resize filter with given width and height
 *
 * @param BoxInterface $size
 * @param string       $filter
 */
public function __construct(BoxInterface $size, $filter = ImageInterface::FILTER_UNDEFINED)
{
    $this->size = $size;
    $this->filter = $filter;
}

/**
 * {@inheritdoc}
 */
public function apply(ImageInterface $image)
{
    return $image->resize($this->size, $this->filter);
}
}

谢谢!

1 个答案:

答案 0 :(得分:0)

我不是100%知道发生了什么,而是添加了

driver:imagick

解决了这个问题。