client/js/image-support/image.js
function draw(fileOrBlob, container, options) {
        var drawPreview = new qq.Promise(),
            identifier = new qq.Identify(fileOrBlob, log),
            maxSize = options.maxSize,
            // jshint eqnull:true
            orient = options.orient == null ? true : options.orient,
            megapixErrorHandler = function() {
                container.onerror = null;
                container.onload = null;
                log("Could not render preview, file may be too large!", "error");
                drawPreview.failure(container, "Browser cannot render image!");
            };

        identifier.isPreviewable().then(
            function(mime) {
                // If options explicitly specify that Orientation is not desired,
                // replace the orient task with a dummy promise that "succeeds" immediately.
                var dummyExif = {
                        parse: function() {
                            return new qq.Promise().success();
                        }
                    },
                    exif = orient ? new qq.Exif(fileOrBlob, log) : dummyExif,
                    mpImg = new qq.MegaPixImage(fileOrBlob, megapixErrorHandler);

                if (registerThumbnailRenderedListener(container, drawPreview)) {
                    exif.parse().then(
                        function(exif) {
                            var orientation = exif && exif.Orientation;

                            mpImg.render(container, {
                                maxWidth: maxSize,
                                maxHeight: maxSize,
                                orientation: orientation,
                                mime: mime,
                                resize: options.customResizeFunction
                            });
                        },

                        function(failureMsg) {
                            log(qq.format("EXIF data could not be parsed ({}).  Assuming orientation = 1.", failureMsg));

                            mpImg.render(container, {
                                maxWidth: maxSize,
                                maxHeight: maxSize,
                                mime: mime,
                                resize: options.customResizeFunction
                            });
                        }
                    );
                }
            },

            function() {
                log("Not previewable");
                drawPreview.failure(container, "Not previewable");
            }
        );

        return drawPreview;
    }
function draw(fileOrBlob, container, options) {
        var drawPreview = new qq.Promise(),
            identifier = new qq.Identify(fileOrBlob, log),
            maxSize = options.maxSize,
            // jshint eqnull:true
            orient = options.orient == null ? true : options.orient,
            megapixErrorHandler = function() {
                container.onerror = null;
                container.onload = null;
                log("Could not render preview, file may be too large!", "error");
                drawPreview.failure(container, "Browser cannot render image!");
            };

        identifier.isPreviewable().then(
            function(mime) {
                // If options explicitly specify that Orientation is not desired,
                // replace the orient task with a dummy promise that "succeeds" immediately.
                var dummyExif = {
                        parse: function() {
                            return new qq.Promise().success();
                        }
                    },
                    exif = orient ? new qq.Exif(fileOrBlob, log) : dummyExif,
                    mpImg = new qq.MegaPixImage(fileOrBlob, megapixErrorHandler);

                if (registerThumbnailRenderedListener(container, drawPreview)) {
                    exif.parse().then(
                        function(exif) {
                            var orientation = exif && exif.Orientation;

                            mpImg.render(container, {
                                maxWidth: maxSize,
                                maxHeight: maxSize,
                                orientation: orientation,
                                mime: mime,
                                resize: options.customResizeFunction
                            });
                        },

                        function(failureMsg) {
                            log(qq.format("EXIF data could not be parsed ({}).  Assuming orientation = 1.", failureMsg));

                            mpImg.render(container, {
                                maxWidth: maxSize,
                                maxHeight: maxSize,
                                mime: mime,
                                resize: options.customResizeFunction
                            });
                        }
                    );
                }
            },

            function() {
                log("Not previewable");
                drawPreview.failure(container, "Not previewable");
            }
        );

        return drawPreview;
    }
function draw ( fileOrBlob , container , options ) { var drawPreview = new qq . Promise ( ) , identifier = new qq . Identify ( fileOrBlob , log ) , maxSize = options . maxSize , // jshint eqnull:true orient = options . orient == null ? true : options . orient , megapixErrorHandler = function ( ) { container . onerror = null ; container . onload = null ; log ( "Could not render preview, file may be too large!" , "error" ) ; drawPreview . failure ( container , "Browser cannot render image!" ) ; } ; identifier . isPreviewable ( ) . then ( function ( mime ) { // If options explicitly specify that Orientation is not desired, // replace the orient task with a dummy promise that "succeeds" immediately. var dummyExif = { parse : function ( ) { return new qq . Promise ( ) . success ( ) ; } } , exif = orient ? new qq . Exif ( fileOrBlob , log ) : dummyExif , mpImg = new qq . MegaPixImage ( fileOrBlob , megapixErrorHandler ) ; if ( registerThumbnailRenderedListener ( container , drawPreview ) ) { exif . parse ( ) . then ( function ( exif ) { var orientation = exif && exif . Orientation ; mpImg . render ( container , { maxWidth : maxSize , maxHeight : maxSize , orientation : orientation , mime : mime , resize : options . customResizeFunction } ) ; } , function ( failureMsg ) { log ( qq . format ( "EXIF data could not be parsed ({}).  Assuming orientation = 1." , failureMsg ) ) ; mpImg . render ( container , { maxWidth : maxSize , maxHeight : maxSize , mime : mime , resize : options . customResizeFunction } ) ; } ) ; } } , function ( ) { log ( "Not previewable" ) ; drawPreview . failure ( container , "Not previewable" ) ; } ) ; return drawPreview ; }
Draw a preview iff the current UA can natively display it. Also rotate the image if necessary.
Draw a preview iff the current UA can natively display it . Also rotate the image if necessary .