我让转换器在这里工作
public class ImageProcessor { public static void Base64TImage(String base64) { try { byte[] btDataFile = new sun.misc.BASE64Decoder().decodeBuffer(base64); File of = new File("yourFile.png"); FileOutputStream osf = new FileOutputStream(of); osf.write(btDataFile); osf.flush(); } catch (IOException ex) { Logger.getLogger(ImageProcessor.class.getName()).log(Level.SEVERE, null, ex); } } public static void main(String args[]){ String base64 = "iVBORw0KGgoAAAANSUhEUgAAAMcAAABqCAYAAAAIh0X2AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAEihJREFUeNrsXctvG8cZH9H0Q35ElOM4aWBYzKvoIa6YOMihKOD1vYDZHHsRBTRAewp96y30oUVvof+BZH3uIdSlPZbqpUAax1TTAmnqxKTi+FXFImW9qUdn6Blp+HF2d/Y9tL4PoGUud2dn5/t+32vm2xnZ3d0lSEhIg5Rl/4yMjETW4O7yexP0T5F+LPrJ8b+Mmuyzs7XV7D5eanTbTxr0e+PU2zc7yAYkE2mEWY4owEFBcYn+qUhgcKWd7hbZ/KFNtpZWGGhq9FOlQGkhS5CeGXBQUEwywdYFBaTt9U2y8XCB7Gx02dc6/ZQQJEhDDw4KjA84MMJZne0dsv5ggWyvrLGvbfopU4DcQPYgDR04KCjGOChKUXaGAYS6WeKrTQEyjSxCGhpwcGAw96cQR4dWW/eEi4UAQRoecMQNDOFirdy5SyP2vRQzc7GuI6uQUgHHO++8o3Xy57MTn5KnadpYaXt1nazdfSgfsqz3ySyyC8lIy0GtxkdMiyfVsbXvH4kAnVGTWSucE0FKkjKa7tSVJIHB6OjZ0/LXfNL3R0LytBw8zmCaO5d050D2iqV482g9kEyyHHYawGB05Pm+2+bQeiAZYzn4kpB6mh0Eqd02tRzjyDYkEyxHNe0OHs4912c9nnxx8QqyDSlVcFCrMUVinM/QpUPHj8FDJWQbUtqWo2JEBw9nSeboYfmQhWxDSg0cPNbIm9LJQ6PHoGt1CVmHlJblMCorpHCt0HogJQ8OqZLPnE4ePYLgQDLCchS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s4v9U9UmDzFus00FbMdrO4xRbzF543GSx2SlVbY7FTOsCOExhePPm/AAMAAP61LDVrLLgAAAAASUVORK5CYII="; Base64TImage(base64); } }
下面是一个基于您的代码的示例:
byte[] btDataFile = new sun.misc.BASE64Decoder().decodeBuffer(base64);
BufferedImage image = ImageIO.read(new ByteArrayInputStream(btDataFile));
JOptionPane.showMessageDialog(null, "", "Image",
JOptionPane.INFORMATION_MESSAGE,
new ImageIcon(image));
我建议您避免使用sun.misc.base64decoder
,因为sun.*包不是受支持的公共接口
的一部分,下面是详细信息。您可以轻松地从Apache Commons切换到Base64,即:
byte[] btDataFile = Base64.decodeBase64(base64);
BufferedImage image = ImageIO.read(new ByteArrayInputStream(btDataFile));
JOptionPane.showMessageDialog(null, "", "Image",
JOptionPane.INFORMATION_MESSAGE,
new ImageIcon(image));
问题内容: 我通过ajax将图像作为base64字符串发送到django。在我的django视图中,我需要调整图像大小并将其保存在文件系统中。 这是一个base64字符串(简体): 我尝试使用以下python代码在PIL中打开此文件: 我正在尝试将上传的图像显示回去,但是firefox抱怨说 我不知道我的错误。 解: 问题答案: 解: 将打开的PIL图像保存到类似文件的对象即可解决此问题。
我想把base64编码的字符串转换成位图,这样我就可以把它放在图像视图中,但是得到的错误像
我想采取一个当前的base64编码的图像,并使用一个简短的哈希说“84dskh”,以“加密”的图像到另一个完全有效的base64编码图像。 原始图像不必经过base64编码,最终我想要原始图像的加密图像,但它仍然是一个可以在img标记中显示的有效图像:。 最好使用JavaScript。
问题内容: 我正在尝试使用jQuery插件即crop.js裁剪/调整用户个人资料图像的大小,该插件通过ajax将用户图像作为base64发送给我的控制器 但我无法解码此base64 字符串作为图像,你们可以指导我如何将base64字符串作为图像保存在服务器上吗? 问题答案: 假设有几件事,您知道输出文件名是什么,并且您的数据以字符串形式出现。我确定您可以修改以下内容以满足您的需求: 请注意,这只是
我正在尝试使用jquery插件裁剪/调整用户配置文件图像的大小,即crop.js,它将用户图像作为base64通过ajax发送到我的控制器
问题内容: 我正在为Firefox / IE构建一个开放式搜索附加组件,并且该图像需要经过Base64编码,因此如何对我拥有的收藏夹图标进行64位编码? 我只熟悉PHP 问题答案: 据我记得,图像数据有一个xml元素。您可以使用此网站对文件进行编码(使用上载字段)。然后,只需将数据复制并粘贴到XML元素即可。 您也可以这样使用PHP来做到这一点: 使用Mozilla指南获取有关创建OpenSear