将画布的内容发送到Java服务器并将其保存为图像 [英] Sending the contents of a canvas to a Java server and saving it as an image

查看:428
本文介绍了将画布的内容发送到Java服务器并将其保存为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,基本上我已经开发了一个简单的图像上传系统。用户选择本地图像(使用HTML5文件/ FileReader API),并且能够在确认结果之前裁剪它。



最终结果在画布中查看所以将其发送到服务器我使用toDataURL。后端服务器是一个NodeJS服务器,然后需要对Java服务器进行REST调用,该服务器将根据数据创建一个映像文件并将其保存到磁盘。



toDataURL的结果是以下形式:data:image / png; base64,ENCODED DATA。



我需要在Java服务器上将字符串转换为正确的二进制 c

;

$ c>部分并基本64解码其余部分。


Okay, basically I've developed a simple image upload system. The user selects a local image (using the HTML5 File / FileReader API) and has the ability to crop it before confirming the result.

The final result is viewed in a canvas so to send it to the server I'm using toDataURL. The backend server is a NodeJS server which then needs to make a REST call to a Java server which will create an image file from the data and save it to disk.

The results of toDataURL are in the form: data:image/png;base64, ENCODED DATA.

What would I need on the Java server to convert the string into it's proper binary representation?

解决方案

You need to remove the data:image/png;base64, part and base 64 decode the rest.

这篇关于将画布的内容发送到Java服务器并将其保存为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆