     x = 1.4
     maxSquare = 5000000  # ios max canvas square
     maxSize = 4096 # ie max canvas dimensions
-    while sW > w
+
+    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

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

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

    df.promise()


      return df.reject('not required')

    # start = new Date()
    sW = originalW = img.width
    sH = img.height
    ratio = sW / sH
    w = Math.floor(Math.sqrt(settings.size * ratio))
