Web 应用程序的图像处理:在服务器上还是在浏览器中?

发布于 2024-10-09 09:12:29 字数 311 浏览 0 评论 0原文

我正在考虑用我编写的程序制作一个网络应用程序,该程序可以演化图像并使用 PIL(Python 图像库)进行图像处理。然而,我对 Web 开发很陌生,不确定是否应该使用 Java Servlet 或(对于 Python)WSGI 之类的东西将应用程序中计算成本相当高的图像处理组件放在 Web 服务器上,或者使用 Javascript 放在浏览器中HTML5 画布。我制作了一个简单的 web.py 应用程序,它在服务器上进行图像处理,但我的初始测试显示,通过 HTTP 将合成图像发送到客户端时存在显着的延迟(它们很小,200x200 像素图像)。你有什么建议?您将如何解决这个问题?

谢谢!

I am looking into making a web app out of a program I wrote that evolves images and uses PIL (Python Imaging Library) for image processing. I am new to web development, however, and am not sure whether I should put the fairly computationally expensive image processing component of my application on the web server using something like Java Servlets or (for python) WSGI, or in the browser using Javascript on the HTML5 canvas. I made a bare bones web.py app that does the image processing on the server, but my initial tests show significant latency in sending the synthesized images over HTTP to the client (they are small, 200x200 pixel images). What is your advice? How would you approach this problem?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暗地喜欢 2024-10-16 09:12:30

您可以在服务器端和浏览器端处理图像。使用 java.awt.Image 在服务器上使用 Java Servlet 生成图像,并使用 HTML5 Canvas 在浏览器中操作/注释图像的呈现。延迟很可能是由于在服务器上处理图像而不是传输到浏览器造成的。由于在服务器上处理图像需要时间,因此您可能需要异步处理图像并以 ajax 方式传递图像,以避免锁定用户的浏览器。您可以使用 JavaScript 中的 Modernizr 检测用户浏览器是否支持 HTML5。

You can process an image on both server side and browser side. Generate your images on the server with a Java Servlet using say java.awt.Image and manipulate/annotate the presentation of images in the browser using HTML5 Canvas. Latency will most likely be caused by processing the image on the server not the transmission to a browser. Because of the time taken to process an image on the server you may need to process the image asynchronously and deliver it in ajax style to avoid locking out the user's browser. You can detect if users browser has HTML5 support using Modernizr from JavaScript.

谜兔 2024-10-16 09:12:30

如果您计划拥有一个高可用性站点,那么使用客户端处理和内存能力是有意义的,但目前使用的大多数浏览器尚未完全支持 HTML5。目前您最好使用服务器端编辑。如果可能的话,您需要在上传时处理图像并存储编辑后的图像,这样您只需每次处理它们。不确定这在您的应用程序中是否可行。

if you plan on having a high availability site, using the clients processing and memory power makes sense, but HTML5 isn't fully supported by the majority of browsers being used just yet. you are probably better off using server side editing at the moment. you will want to process the images on upload if possible and store the edited image so that you only have to process them each one time. not sure if this is possible in your app.

心病无药医 2024-10-16 09:12:30

您可以考虑在服务器端实施一些云处理解决方案。通过这种方式,它将随着用户数量的增加而扩展。您没有提到所完成的图像处理类型,但对于某些复杂的算法,这可能会变得非常密集。

You may consider to implement some Cloud Processing solution server side. In this way it will be scalable with the number of users. You don't mention the type of image processing that is done but for some complicated algorithms this can become very intensive.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文