     return CGRect(origin: (size - newSize).mid, size: newSize)
 }
 
+func center(size: CGSize, imageSize: CGSize) -> CGRect {
+    let origin = CGPoint(x: (size.width - imageSize.width) / 2.0,
+                         y: (size.height - imageSize.height) / 2.0)
+    return CGRect(origin: origin, size: imageSize)
+}
+
+func top(size: CGSize, imageSize: CGSize) -> CGRect {
+    let origin = CGPoint(x: (size.width - imageSize.width) / 2.0, y: 0.0)
+    return CGRect(origin: origin, size: imageSize)
+}
+
+func bottom(size: CGSize, imageSize: CGSize) -> CGRect {
+    let origin = CGPoint(x: (size.width - imageSize.width) / 2.0,
+                         y: size.height - imageSize.height)
+    return CGRect(origin: origin, size: imageSize)
+}
+
+func left(size: CGSize, imageSize: CGSize) -> CGRect {
+    let origin = CGPoint(x: 0, y: (size.height - imageSize.height) / 2.0)
+    return CGRect(origin: origin, size: imageSize)
+}
+
+func right(size: CGSize, imageSize: CGSize) -> CGRect {
+    let origin = CGPoint(x: size.width - imageSize.width,
+                         y: (size.height - imageSize.height) / 2.0)
+    return CGRect(origin: origin, size: imageSize)
+}
+
+func topLeft(size: CGSize, imageSize: CGSize) -> CGRect {
+    return CGRect(origin: CGPoint.zero, size: imageSize)
+}
+
+func topRight(size: CGSize, imageSize: CGSize) -> CGRect {
+    let origin = CGPoint(x: size.width - imageSize.width, y: 0)
+    return CGRect(origin: origin, size: imageSize)
+}
+
+func bottomLeft(size: CGSize, imageSize: CGSize) -> CGRect {
+    let origin = CGPoint(x: 0, y: size.height - imageSize.height)
+    return CGRect(origin: origin, size: imageSize)
+}
+
+func bottomRight(size: CGSize, imageSize: CGSize) -> CGRect {
+    let origin = CGPoint(x: size.width - imageSize.width,
+                         y: size.height - imageSize.height)
+    return CGRect(origin: origin, size: imageSize)
+}
 
 #if os(iOS) || os(tvOS)
     

            return aspectFit(size: size, imageSize: image.size)
        case .scaleAspectFill:
            return aspectFill(size: size, imageSize: image.size)
        default:
            return CGRect(origin: CGPoint.zero, size: size)
        }
    }
}

    }
    
    public func scale(image: UIImage) -> UIImage? {
        var alpha: CGFloat = 0.0
        var white: CGFloat = 0.0
        backgroundColor.getWhite(&white, alpha: &alpha)
