demos/layer-effects/index.js
function fileToCanvas(file, done) {
  var canvas = document.createElement('canvas');
  var ctx = canvas.getContext('2d');
  var img = document.createElement('img');
  img.onload = function() {
    canvas.width = img.naturalWidth;
    canvas.height = img.naturalHeight;
    ctx.drawImage(img, 0, 0);
    done(null, canvas);
  };
  img.onerror = function(err) {
    done(err);
  };
  img.src = URL.createObjectURL(file);
}
function fileToCanvas(file, done) {
  var canvas = document.createElement('canvas');
  var ctx = canvas.getContext('2d');
  var img = document.createElement('img');
  img.onload = function() {
    canvas.width = img.naturalWidth;
    canvas.height = img.naturalHeight;
    ctx.drawImage(img, 0, 0);
    done(null, canvas);
  };
  img.onerror = function(err) {
    done(err);
  };
  img.src = URL.createObjectURL(file);
}
function fileToCanvas ( file , done ) { var canvas = document . createElement ( 'canvas' ) ; var ctx = canvas . getContext ( '2d' ) ; var img = document . createElement ( 'img' ) ; img . onload = function ( ) { canvas . width = img . naturalWidth ; canvas . height = img . naturalHeight ; ctx . drawImage ( img , 0 , 0 ) ; done ( null , canvas ) ; } ; img . onerror = function ( err ) { done ( err ) ; } ; img . src = URL . createObjectURL ( file ) ; }
Convert an image file into a canvas.
Convert an image file into a canvas .