Guest User

Untitled

a guest
May 21st, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. // Get the image
  2. var image = document.getElementById('douglas'),
  3. // Make a canvas
  4. canvas = document.createElement('canvas'),
  5. data;
  6.  
  7. canvas.height = image.height;
  8. canvas.width = image.width;
  9. // Put image on canvas
  10. canvas.getContext('2d').drawImage(image, 0, 0);
  11. // Get base64 encoded data, and un-convert it
  12. data = canvas.toDataURL();
  13. data = atob(data.slice(data.indexOf(',') + 1));
  14. // data is the binary data
Add Comment
Please, Sign In to add comment