       reader.readAsArrayBuffer(file)
 
     readNext = ->
+      startPos = pos
       readToView file.slice(pos, pos += 4), (view) ->
         if view.byteLength != 4 or view.getUint8(0) != 0xff
           return df.reject('corrupted')

        readToView file.slice(pos, pos += length), (view) ->
          if view.byteLength != length
            return df.reject('corrupted')
          df.notify(marker, view)
          readNext()

    df = $.Deferred()

        op = ns.reduceImage(img, settings)
        op.progress (progress) ->
          console.log(progress)
        op.fail(df.reject)
        op.done (canvas) ->
          # start = new Date()
          utils.canvasToBlob canvas, 'image/jpeg', settings.quality or 0.95,
            (blob) ->
              # console.log('to blob: ' + (new Date() - start))
              if exif
                op = ns.replaceJpegChunk(blob, 0xe1, [exif])
                op.done(df.resolve)
                op.fail ->
                  df.resolve(blob)
              else
                df.resolve(blob)

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