     [w, h] = settings.size
 
     if img.width < w and img.height < h
-      df.reject('not required')
+      return df.reject('not required')
 
+    # start = new Date()
+
+    if img.width / w > img.height / h
+      h = img.height * w / img.width
     else
-      # start = new Date()
+      w = img.width * h / img.height
 
-      if img.width / w > img.height / h
-        h = img.height * w / img.width
-      else
-        w = img.width * h / img.height
+    canvas = document.createElement('canvas')
+    canvas.width = w
+    canvas.height = h
+    canvas.getContext('2d').drawImage(img, 0, 0, w, h);
 
-      canvas = document.createElement('canvas')
-      canvas.width = w
-      canvas.height = h
-      canvas.getContext('2d').drawImage(img, 0, 0, w, h);
-
-      # console.log('draw: ' + (new Date() - start))
-      df.resolve(canvas)
+    # console.log('draw: ' + (new Date() - start))
+    df.resolve(canvas)
 
     df.promise()
 

    exifTags = null

    if not (URL and DataView)
      df.reject('support')

    else
      op = ns.readJpegChunks(file)
      op.progress (marker, view) ->
        if marker == 0xe1
          exifTags = ns.parseExifTags(view)
          if exifTags?
            exif = view.buffer
      op.always ->
        # start = new Date()
        img = new Image()
        img.onload = ->
          # console.log('load: ' + (new Date() - start))
          op = ns.reduceImage(img, settings)
          op.fail df.reject
          op.done (canvas) ->
            # start = new Date()
            utils.canvasToBlob canvas, 'image/jpeg', settings.quality or 0.95,
              (blob) ->
                if exif
                  intro = new DataView(new ArrayBuffer(6))
                  intro.setUint32(0, 0xffd8ffe1)
                  intro.setUint16(4, exif.byteLength + 2)
                  blob = new Blob([
                    intro, exif, blob.slice(2, blob.size)
                  ], {type: blob.type})
                # console.log('to blob: ' + (new Date() - start))
                df.resolve(blob)

        img.onerror = ->
          df.reject('not image')

        img.src = URL.createObjectURL(file)

    df.promise()


    df = $.Deferred()

    if not (FileReader and DataView)
      return df.reject('support')

    # start = new Date()
    pos = 2

    readToView file.slice(0, 2), (view) ->
      if view.getUint16(0) != 0xffd8
        return df.reject('not jpeg')
      readNext()

    df.promise()

