将图像转换为不带画布的base64 [英] Convert image to base64 without canvas

查看:111
本文介绍了将图像转换为不带画布的base64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将图像转换为base64编码。我知道用帆布很容易。但问题是它也应该在IE8中运行。但IE8不支持HTML5,所以我不能使用画布。有没有其他方法使用javaScript将图像转换为base64?



谢谢

解决方案

如果需要,简单的答案是否定的在客户端完成。 canvas元素是将图像转换为位图数据或数据uris的唯一方式(即使安全限制可能会阻止这种情况发生)。

你也许可以绕过这使用Flash,但当然,这将需要客户端安装Flash。



或者设置一个外部Web服务,您可以上传图像并返回数据您需要。



对于IE8及更低版本,没有任何选项可供选择(exCanvas为您提供画布绘制功能,但无法提供此处需要的位图数据)。基本上,对于IE8,您将需要一台服务器。


I need to convert an image to base64 encoding. I know its very easy with canvas. but the problem is that it should also run in IE8. but IE8 dont support HTML5 so i can't do it using canvas. Is there any other method using javaScript to convert image to base64 ?

Thanks

解决方案

Simple answer is no if this needs to be done on client side. The canvas element is the only way to convert an image to bitmap data or data-uris (and even then security restriction may apply preventing this).

You can maybe get around this using Flash but of course that would require the client to have Flash installed.

Or setting up an external web service where you can upload the image and have it return the data you need.

For IE8 and lower there are no options out of the box (exCanvas gives you canvas drawing capabilities but can't provide bitmap data which is needed here). Basically, for IE8 you will need a server.

这篇关于将图像转换为不带画布的base64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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