             return self
 
         } else {
-            //println("newSize: \(newSize)")
+            //println("B scaleToMinSideLength newSize: \(newSize)")
             UIGraphicsBeginImageContextWithOptions(newSize, false, 1.0)
-            let rect = CGRectMake(0, 0, floor(newSize.width), floor(newSize.height))
+            let rect = CGRectMake(0, 0, newSize.width, newSize.height)
             self.drawInRect(rect)
             let newImage = UIGraphicsGetImageFromCurrentImageContext()
             UIGraphicsEndImageContext()


            let newWidth = pixelSideLength
            let newHeight = (pixelSideLength / pixelWidth) * pixelHeight
            newSize = CGSize(width: newWidth, height: newHeight)
        }


        if scale == UIScreen.mainScreen().scale {
            let newSize = CGSize(width: newSize.width / scale, height: newSize.height / scale)
            //println("newSize: \(newSize)")

            UIGraphicsBeginImageContextWithOptions(newSize, false, scale)
            let rect = CGRectMake(0, 0, floor(newSize.width), floor(newSize.height))
            self.drawInRect(rect)
            let newImage = UIGraphicsGetImageFromCurrentImageContext()
            UIGraphicsEndImageContext()


            let newHeight = pixelSideLength
            let newWidth = (pixelSideLength / pixelHeight) * pixelWidth
            newSize = CGSize(width: floor(newWidth), height: floor(newHeight))

        } else {

