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.
            Asked
            
        
        
            Active
            
        
            Viewed 2,536 times
        
    1 Answers
3
            You could use the canvas element and draw the image using drawImage() onto it, then use toDataURL() to get the base64 encoded image.
 
    
    
        stewe
        
- 41,820
- 13
- 79
- 75
- 
                    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? – Buterrip Aug 28 '11 at 23:27
- 
                    Maybe there is another way, but for those functions mentioned, you need a `canvas` element – stewe Aug 28 '11 at 23:43
- 
                    Ok, could you please give me a example? – Buterrip Aug 28 '11 at 23:57
- 
                    Found a good example here: http://stackoverflow.com/questions/934012/get-image-data-in-javascript/934925#934925 – stewe Aug 29 '11 at 00:14
