     ///
     /// - Returns: A new image with the given color filled.
     public func tint(with color: UIColor) -> UIImage! {
-        UIGraphicsBeginImageContextWithOptions(size, false, scale)
+        UIGraphicsBeginImageContextWithOptions(scaledSize, false, scale)
         defer { UIGraphicsEndImageContext() }
         guard let cgImage = self.cgImage, let context = UIGraphicsGetCurrentContext() else { return nil }
-        context.translateBy(x: 0.0, y: size.height)
+        context.translateBy(x: 0.0, y: scaledHeight)
         context.scaleBy(x: 1.0, y: -1.0)
         context.setBlendMode(.normal)
-        let rect = CGRect(origin: .zero, size: size)
+        let rect = CGRect(origin: .zero, size: scaledSize)
         context.clip(to: rect, mask: cgImage)
         color.setFill()
         context.fill(rect)

        return borderedImage.round(cornerRadius, border: borderWidth)
    }
    /// Creates a copy of this image that is scale-aspect-fit to the thumbnail size using `ImageIO`.
    ///
    /// - Parameter size: A size of thumbnail to scale-aspect-fit to.
    ///
    /// - Returns: A copy of the receiver that is squared to the thumbnail size.
    public func thumbnail(scalesToFit size: CGFloat) -> UIImage! {
        guard let data = UIImageJPEGRepresentation(self, 1.0) as CFData? else { return nil }
        // Create an image source from NSData; no options.
        guard let imageSource = CGImageSourceCreateWithData(data, nil) else { return nil }
        // Package the integer as a  CFNumber object. Using CFTypes allows you
        // to more easily create the options dictionary later.
        var intSize = Int(size)

        case bottomLeft
        case bottomRight
    }
    /// Creates a copy of the receiver that is cropped to the given rectangle in pixels. Animated image supported.
    ///
    /// The bounds will be adjusted using `CGRectIntegral`.
    ///
