Symfony2:调整上传图像的大小
在 Symfony2 中上传图片时有没有办法调整图片大小?
ImagineAvalancheBundle 只允许在检索图像时将图像大小调整为缩略图,这对我来说并不是真正的性能。
此外,发布数据时检索的 UploadedFile 对象似乎没有调整大小的方法......
有什么想法吗?
Is there any way to resize pictures while uploading them in Symfony2 ?
The ImagineAvalancheBundle only allows to resize images to thumbnails when retrieving them, which is not really performant to me.
Besides, the UploadedFile object retreived when posting data doesn't seems to have resizing methods...
Any Idea ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了你所要求的同样的问题。
主要问题是捆绑包直接调整图像大小和/或裁剪图像。
因此,如果处理大图像并且每页需要很多图像,则可能会花费大量时间。
因此,我通过在 imageupload 之后直接调用图像的
resize()
函数来解决此问题。因此,我将调整大小的图像保存(复制)到服务器上的文件系统中。显然,我将图像的路径存储到数据库中,以便在需要时可以直接加载它。
我尝试了 imageresize 捆绑包中包含的 memcache,但在我的情况下它不起作用。
I had the same problem you are asking for.
The main issue is that the bundle resizes and/or crops the images directly.
So that can take a lot of time with big images and if many images are expected per page.
So I've fix this issue by calling directly after imageupload the
resize()
function to the image.Hence, I save (copy) the resized image to the filesystem at the server. Obviously I store the path of the image into the database to can load it directly if needed.
I tried the included memcache of the imageresize bundle but in my case it doesn't work.
对于我实际开发的项目,我遇到了同样的问题。我在网上搜索了很多,但没有发现任何真正具有性能并且对于非技术人员也易于使用的东西。
我创建了一个捆绑包,以便能够使用 jquery 文件上传 上传并使用 jcrop 以及其他一些功能。
ComurImageBundle
I had the same problem for a project that i'm actually developing. I searched a lot on the net and found nothing realy performant and also easy to use for non-tech people.
I created a bundle to be able to upload with jquery file upload and crop with jcrop with some other functions.
ComurImageBundle
您的目标到底是什么?调整大小和裁剪?其他 ?
我不明白为什么你说捆绑包大小调整为缩略图只有因为你可以通过 config 精确定义调整大小预设:
What is exactly your goal ? Resize and crop ? Other ?
I don't understand why you say that the bundle resize to thumbnail only as you can define precisely your resize preset through config :