canvas-image-uploader.js
function(file, $canvas, callback) {
            this.newImage();
            if (!file)
                return;

            var reader = new FileReader();
            reader.onload = function (fileReaderEvent) {
                image.onload = function () { readImageToCanvasOnLoad(this, $canvas, callback); };
                image.src = fileReaderEvent.target.result;      // The URL from FileReader

            };
            reader.readAsDataURL(file);
        }
function(file, $canvas, callback) {
            this.newImage();
            if (!file)
                return;

            var reader = new FileReader();
            reader.onload = function (fileReaderEvent) {
                image.onload = function () { readImageToCanvasOnLoad(this, $canvas, callback); };
                image.src = fileReaderEvent.target.result;      // The URL from FileReader

            };
            reader.readAsDataURL(file);
        }
function ( file , $canvas , callback ) { this . newImage ( ) ; if ( ! file ) return ; var reader = new FileReader ( ) ; reader . onload = function ( fileReaderEvent ) { image . onload = function ( ) { readImageToCanvasOnLoad ( this , $canvas , callback ) ; } ; image . src = fileReaderEvent . target . result ; // The URL from FileReader } ; reader . readAsDataURL ( file ) ; }
Draw an image from a file on a canvas.
@param file The uploaded file.
@param $canvas The canvas (jQuery) object to draw on.
@param callback Function that is called when the operation has finished.
Draw an image from a file on a canvas .