       return df.reject('not required')
 
     # start = new Date()
-    sW = img.width
+    sW = originalW = img.width
     sH = img.height
     ratio = sW / sH
     w = Math.floor(Math.sqrt(settings.size * ratio))

      canvas.getContext('2d').drawImage(img, 0, 0, sW, sH)
      img = canvas

    # console.log('draw: ' + (new Date() - start))
    df.resolve(canvas)

    df.promise()


    x = 1.4
    maxSquare = 5000000  # ios max canvas square
    maxSize = 4096 # ie max canvas dimensions

    do run = ->
      if sW <= w
        # console.log('draw: ' + (new Date() - start))
        df.resolve(img)
        return

      sW = Math.round(sW / x)
      sH = Math.round(sH / x)
      if sW < w * x
