我可以将图像从base64转换为二进制客户端吗? [英] Can I convert an image FROM base64 to binary client side?

查看:101
本文介绍了我可以将图像从base64转换为二进制客户端吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用canvas元素处理图片,然后通过
canvasImg.toDataURL(image / jpeg,1.0)
是否可以将结果转换为客户端的二进制图像文件?我试图避免

After manipulating an image using a canvas element and then getting the result via canvasImg.toDataURL( "image/jpeg", 1.0 ), is it possible to convert the result into a binary image file client-side? I am trying to avoid


  1. 往返服务器和

  2. 将服务器的RAM一个GD进程。

目标是编辑图像并将其作为文件获取到s3而不用触摸我的服务器。 >

The goal is to edit the image and get it onto s3 as a file without touching my server.

推荐答案

丹尼尔·C 的评论导致我的解决方案(这里将数据URI转换为文件,然后附加到FormData )。

Daniel C's comment led me to the solution (here at Convert Data URI to File then append to FormData).

我需要的另一件事是 URL.createObjectURL(blob) ,它给了我一个字符串句柄传递文件。

The one extra thing I needed was URL.createObjectURL(blob), which gave me a string handle to pass the file around.

这篇关于我可以将图像从base64转换为二进制客户端吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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