上传前是否可以优化/缩小图像?
我正在开发一个可以处理许多图像上传的网络应用程序。 用户很可能位于互联网连接速度较慢的地区,我希望通过在上传之前压缩图像来节省他们的上传时间。
我已经看到 Aurigma Image Uploader 使用 java applet 或 active x 实现了这一点,但它很昂贵,我宁愿使用开源的东西或者至少便宜一点。 理想情况下,如果可能的话,我想自己推出。
我正在 Ruby on Rails 上进行开发,如果这有什么区别的话……
谢谢!
编辑只是为了澄清:我不介意解决方案是否使用 activeX 或小程序(尽管 js 是理想的) - 我只是在这个开发阶段寻找比 Aurigma 便宜一点的东西。
此外,用户自己缩小图像可能不可行,因为在许多情况下他们会直接从网吧或其他公共互联网点上传。
I am working on a web application that will deal with many image uploads. Its quite likely that the users will be in areas with slow internet connections and I'm hoping to save them upload time by compressing the images before uploading.
I have seen that Aurigma Image Uploader achieves this using a java applet or active x but it's expensive and I'd rather something open source or at least a little cheaper. Ideally I'd like to roll my own if its at all possible.
I'm developing on Ruby on Rails if that makes any difference..
Thanks!
Edit just to clarify: I don't mind if the solution uses activeX or an applet (although js is ideal) - I'm just looking for something a little cheaper than Aurigma at this stage of development.
Also, it may not be feasible for users to shrink the image themselves as in many instances they will uploading directly from an internet cafe or other public internet spot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
一般来说,不可能用 JavaScript 编写图像压缩器。 对不起。
您需要使用某种插件,正如您提到的,其他网站使用 Java。
似乎可以在 ActionScript(即 Flash)中编写一些东西来编码 JPEG,这将比您提到的 Java 插件吸引更多的受众。 这是一篇博客文章的链接关于 PNG 和 ActionScript 中的 JPEG 编码器。
这是另一篇博客文章,其中演示了 ActionScript 中的内联 JPEG 编码器。
Generally, it isn't possible to write an image compressor in JavaScript. Sorry.
You'll need to use a plugin of some sort, and as you mention, other sites use Java.
It appears to be possible to write something to encode a JPEG in ActionScript (i.e. Flash), which will reach a much larger audience than the Java plugin you mention. Here's a link to a blog post talking about PNG & JPEG encoders in ActionScript.
Here's another blog post with a demo of an inlined JPEG encoder in ActionScript.
仅当您使用 Flash 或 Silverlight(唯一的跨平台方式)
http ://www.jeff.wilcox.name/2008/07/fjcore-source/可能值得一读。
Only if you use Flash or Silverlight (only way to be cross-platform)
http://www.jeff.wilcox.name/2008/07/fjcore-source/ may be worth a read.
如果不使用 applet 或 activex(仅在 Windows 中),您将无法在客户端 PC 上执行任何操作。
Without using applets or activex (only in windows) you can't execute anything on a client pc.
可能不会,但您始终可以坚持认为超过 x 大小的图像上传不会成功。
Probably not, but you can always insist that image uploads over x size will not succeed.
这是一个可以强制他们插入较小图像的应用程序吗? 在这种情况下,您可以先获取尺寸以验证其是否符合标准。 这就是 Facebook 过去处理个人资料图片的方式。 如果太大了他们就不会接受。
Is this an application where you can force them to insert a smaller image. In that case you could grab the size first to verify it fits standards. This is what facebook used to do with profile pictures. If it was too big they wouldn't take it.