0

I need to convert image that are in a webpage to base64 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.

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

4 Comments

In order to use canvas element this would not be fine, because i'm doing a script to interact with another page. There's not another way? Or can i use that functions without calling canvas element?
Maybe there is another way, but for those functions mentioned, you need a canvas element
Ok, could you please give me a example?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.