       __calcImgSizes: ->
         @__originalWidth = @__img[0].width
         @__originalHeight = @__img[0].height
-        if @__originalWidth > @__wrapWidth or @__originalHeight > @__wrapHeight or @__options.upscale
-          if @__wrapWidth / @__wrapHeight < @__originalWidth / @__originalHeight
-            @__resizedWidth = @__wrapWidth
-            @__resizedHeight = Math.floor @__originalHeight / @__originalWidth * @__resizedWidth
-          else
-            @__resizedHeight = @__wrapHeight
-            @__resizedWidth = Math.floor @__originalWidth / @__originalHeight * @__resizedHeight
-        else
-          @__resizedWidth = @__originalWidth
-          @__resizedHeight = @__originalHeight
+        [@__resizedWidth, @__resizedHeight] = 
+          fitSize @__originalWidth, @__originalHeight, @__wrapWidth, @__wrapHeight, @__options.upscale
         @__img.attr
           width: @__resizedWidth
           height: @__resizedHeight

        @__currentCoords

      destroy: ->
        @__widgetElement.remove()
        # TODO: full destroy somehow

      __buildUrl: (coords) ->
        scaleRatio = @__resizedWidth / @__originalWidth

          jCropOptions.setSelect = [0, 0, width, height]
        else
          jCropOptions.setSelect = [0, 0, @__resizedWidth, @__resizedHeight]
        setApi = (api) => @__jCropApi = api
        @__img.Jcrop jCropOptions, -> setApi this
