上传和图像压缩
我在客户的一个网站上使用 Uploadify,允许他们一次将大量图片上传到他们的照片库。
我最近发现了一些问题。他们似乎上传大照片(3 MB 及以上)。我想知道,是否可以在客户端压缩(减小它们的大小),而不是在服务器上进行压缩(就像 facebook 那样)。 我知道我可以轻松地在服务器上完成此操作,但我现在正在开发另一个项目,我预计会有大量照片上传。处理所有这些将需要大量的 CPU 时间。所以我想,我会询问客户端处理。
谢谢。
I am using Uploadify on one of my client's web sites to allow them to upload a large amount of pictures at once to their photo gallery.
I am seeing issues lately. They seem to upload large photographs (3 MB and above). I am wondering, is it possible to compress (reduce their size) on the client side, instead of doing it on the server (just like facebook does it).
I know I could easily do it on the server, but I am working on another project right now, where I am expecting a large flow of photo uploads. It would require significant amount of CPU time to process them all. So I thought, I'd ask about the client side processing.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将无法使用 zip 或类似算法对 JPG 图像进行太多压缩 - 它们本身已经接近最佳状态。您必须在客户端调整它们的大小。为此,请参阅
上传前调整图像大小
jquery + flash:寻找在上传之前调整图像大小的插件
上传到服务器之前使用 JavaScript 调整客户端图像大小
You won't be able to compress JPG images much using zip or similar algorithms - they are already close to optimum in themselves. You'd have to resize them on client side. For that, see e.g.
Image resize before upload
jquery + flash: looking for plugin that resize images before upload
Image resizing client-side with javascript before upload to the server
图像调整大小与图像压缩不同。
调整大小和压缩之间的区别:
压缩时,您会得到尺寸相同但质量较低的图像。
当您调整大小时,您会在不同尺寸上获得相同的质量。
不管怎样,我开发了一个名为 JIC 的 javascript 库来解决这个问题。它允许您使用 javascript 在客户端 100% 压缩 jpg 和 png,无需外部库!
您可以在这里尝试演示:http://makeitsolutions.com/labs/jic 并获取源代码这里:https://github.com/brunobar79/JIC
希望你喜欢它。
Image resize is not the same as image compression.
Difference between resize and compression:
When you compress you get an image with same dimensions at lower quality.
When you resize you are getting same quality at different dimensions.
Anyway, I developed a javascript library called JIC to solve that problem. It allows you to compress jpg and png on the client side 100% with javascript and no external libraries required!
You can try the demo here : http://makeitsolutions.com/labs/jic and get the sources here : https://github.com/brunobar79/J-I-C
Hope you like it.