开发者

Convert image to base64 javascript on firefox

开发者 https://www.devze.com 2023-03-31 14:47 出处:网络
I need to convert image that are in a webpage to base64开发者_JAVA百科 over greasemonkey or firefox .xpi extension.

I need to convert image that are in a webpage to base64开发者_JAVA百科 over greasemonkey or firefox .xpi extension. How can i do it? I know that i have btoa() function, but i only can use it with strings, not with images. Little help here. Thanks.


You could use the canvas element and draw the image using drawImage() onto it, then use toDataURL() to get the base64 encoded image.

see: https://developer.mozilla.org/en/html/canvas

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号