robertvari

Read image data

Jan 5th, 2020
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function set_canvas_image(f, element) {
  2.     let reader = new FileReader();
  3.  
  4.     // Closure to capture the file information.
  5.     reader.onload = (function() {
  6.     return function(e) {
  7.         // Render thumbnail.
  8.         element.src = e.target.result
  9.     };
  10.     })(f);
  11.  
  12.     // Read in the image file as a data URL.
  13.     reader.readAsDataURL(f);
  14.  
  15. }
Advertisement
Add Comment
Please, Sign In to add comment