 
       # This is a bugfix for iOS' scaling bug.
       drawImageIOSFix ctx, img, resizeInfo.srcX ? 0, resizeInfo.srcY ? 0, resizeInfo.srcWidth, resizeInfo.srcHeight, resizeInfo.trgX ? 0, resizeInfo.trgY ? 0, resizeInfo.trgWidth, resizeInfo.trgHeight
+
+      #I have this code in JS, don't know how to write in coffee, but the thumbnail drawing seems to perform better this way
+      #var diff = [0, 0];
+      #diff = _this.compareWidthHeight(img.width, img.height);
+      #drawImageIOSFix(ctx, img, (_ref = diff[0] / 2) != null ? _ref : 0, (_ref1 = diff[1] / 2) != null ? _ref1 : 0, img.width - diff[0], img.height - diff[1], (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
 
       thumbnail = canvas.toDataURL "image/png"
 

    else
      @options.accept.call this, file, done

  addFile: (file) ->
    file.upload =
      progress: 0
      # Setting the total upload size to file.size for the beginning
      # It's actual different than the size to be transmitted.
      total: file.size
      bytesSent: 0
    @files.push file

    file.status = Dropzone.ADDED

    @emit "addedfile", file

    @_enqueueThumbnail file

    @accept file, (error) =>
      if error

        @enqueueFile file if @options.autoQueue # Will set .accepted = true
      @_updateMaxFilesReachedClass()

  resizeImg: (file, callback) ->
        
    img = document.createElement "img"
    _this = this
    img.onload = =>
      file.width = img.width
      file.height = img.height

      resizeInfo = @options.resize.call @, file, "imageResize"

      resizeInfo.trgWidth ?= resizeInfo.optWidth
      resizeInfo.trgHeight ?= resizeInfo.optHeight

      canvas = document.createElement "canvas"
      ctx = canvas.getContext "2d"
      canvas.width = resizeInfo.trgWidth
      canvas.height = resizeInfo.trgHeight

      # This is a bugfix for iOS' scaling bug.
      drawImageIOSFix ctx, img, cX ? 0, resizeInfo.srcY ? 0, resizeInfo.srcWidth, resizeInfo.srcHeight, resizeInfo.trgX ? 0, resizeInfo.trgY ? 0, resizeInfo.trgWidth, resizeInfo.trgHeight

      image = canvas.toDataURL "image/png", @options.imageQuality
      file = _this.dataUriToBlob image

      callback() if callback?

    img.src = file

  dataUriToBlob: (dataURI) ->
    byteString = if dataURI.split(',')[0].indexOf('base64') >= 0 then atob dataURI.split(',')[1] else unescape dataURI.split(',')[1]
    mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]

    ab = new ArrayBuffer byteString.length
    ia = new Uint8Array ab

    i = 0
    while i < byteString.length
      ia[i] = byteString.charCodeAt(i)
      i++

    dataView = new DataView(ab)
    blob = new Blob([ ia ], type: mimeString)
    
    blob


  compareWidthHeight : (width, height) ->
    diff = []
    if width > height
      diff[0] = width - height
      diff[1] = 0
    else
      diff[0] = 0
      diff[1] = height - width
    
    diff

  # Wrapper for enqueueFile
  enqueueFiles: (files) -> @enqueueFile file for file in files; null
