Created
March 18, 2010 20:06
-
-
Save tim-smart/336808 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Get the image | |
| var image = document.getElementById('douglas'), | |
| // Make a canvas | |
| canvas = document.createElement('canvas'), | |
| data; | |
| canvas.height = image.height; | |
| canvas.width = image.width; | |
| // Put image on canvas | |
| canvas.getContext('2d').drawImage(image, 0, 0); | |
| // Get base64 encoded data, and un-convert it | |
| data = canvas.toDataURL(); | |
| data = atob(data.slice(data.indexOf(',') + 1)); | |
| // data is the binary data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment