在 App Engine 中调整大图像的大小
我在 Google App Engine 上有一个应用程序,可以接受用户上传的图像。 我设想的问题是,用户将直接从相机上传这些图像,并且文件大小通常大于 1MB,这是图像 API(将用于调整图像大小)的限制。
接受上传 1.5MB 图像文件并将其大小调整到 1MB 以下的最佳方法是什么?
I've got an app on Google App Engine that will accept image uploads from users. The problem that I envision is that users will upload these images directly from their cameras, and file sizes are often greater than 1MB, which is the limit for the image API (which would be used to resize the images).
What's the best way to accept the upload of say a 1.5MB image file, and resize it to under 1MB?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
虽然 App Engine 文档中对此并不清楚,但通过使用 Blobstore 和图像处理服务的组合可以实现这一点。
您必须:
我已经写了一篇关于此的文章 -> http://socialappdev.com/uploading-and-re-在 app-engine-11-2010 上调整大图像大小。
While this is not clear in the App Engine documentation, this is possible by using a combination of the Blobstore and the Image Manipulation Service.
You must:
I've written up a post about this -> http://socialappdev.com/uploading-and-re-sizing-large-images-on-app-engine-11-2010.
这里有两种(类似的)方法来解决这个问题:
POST
将其返回到您的应用程序。 当然,所有这些交互都需要某种授权,这样就不会被滥用。 或者,将图像直接POST
到外部服务器,但随后您必须将其他表单数据发送回您的应用程序,或使用单独的表单来上传图像。POST
数据。我推荐第 2 点,因为它不需要您绕过 Google App Engine 限制,并且由于您的用户直接从相机上传图像,他们可能无论如何都想对它们做一些事情(例如裁剪)。
Here are two (similar) ways to solve this:
POST
s it back to your application. All this interaction would need some kind of authorization of course, so that it can't be abused. Alternatively,POST
the image directly to your external server, but then you have to either send the other form data back to your application, or use a separate form for the image upload.POST
data.I recommend point 2, because it doesn't require you to go around Google App Engine limitations and since your users are uploading images straight from the camera, they will probably want to do something with them anyways (such as crop.)
这是一个难题。 “显而易见”的答案,使用 google.appengine.api.images .resize,不起作用,因为它太大了。 :) 因此,您必须使用第三方软件,无论是在服务器上(由于 App Engine 的限制,这会很棘手)还是在客户端上(例如 Java 上传器)。
That's a conundrum. The "obvious" answer, using google.appengine.api.images.resize, won't work because it's too big. :) So you will have to use third-party software, either on the server (which will be tricky because of App Engine's limitations) or the cilent (e.g. a Java uploader).