【问题标题】:how to resize the original image after upload with LiipImagineBundle on symfony3?在 symfony3 上使用 LiipImagineBundle 上传后如何调整原始图像的大小?
【发布时间】:2016-10-07 08:48:47
【问题描述】:

我看到了这个链接,它很接近我想要的。 Use LiipImagineBundle to Resize Image after Upload?

我将 symfony 3 与捆绑包 LiipImagineBundle 一起使用。 我只想在上传后在类控制器中调整原始图像的大小。 我不想在缓存文件夹上创建缩略图。

让我们看看下面的示例: 如果用户上传一个 1800*1200 的文件,我想在文件系统上将其调整为 800*600,并且我不想保留 1800*1200 的文件。

LiipImagineBundle 可以吗?

谢谢。

【问题讨论】:

    标签: image symfony upload resize liipimaginebundle


    【解决方案1】:

    你可以通过像这样实现一个特殊的过滤器(裁剪)来做到这一点

    # LiipImagineBundle
    liip_imagine:
        resolvers:
            default:
                web_path:
                    web_root: ~
                    cache_prefix: media/cache
        filter_sets:
            image_xlarge:
                filters:
                    crop: { size: [800, 600], mode: outbound }
    

    推荐人http://symfony.com/doc/current/bundles/LiipImagineBundle/filters/sizing.html#cropping-images

    【讨论】:

    • hi Yamen 感谢您的回复,但我想从控制器调整它的大小。上传文件后
    • 没人有主意吗?
    • 实际上这将创建一个具有新尺寸的新图像,因此您可以做的是创建新图像并删除旧图像
    猜你喜欢
    • 2013-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-06
    • 2020-03-20
    • 2015-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多