Created
August 5, 2017 06:46
-
-
Save m25lazi/820cab17b1748b18faa96f9e4d9fd5c6 to your computer and use it in GitHub Desktop.
UIImage extension for using in Inception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func buffer() -> CVPixelBuffer? { | |
return UIImage.buffer(from: self) | |
} | |
static func buffer(from image: UIImage) -> CVPixelBuffer? { | |
// as explained in https://www.hackingwithswift.com/whats-new-in-ios-11 | |
// ... | |
} | |
func resizeTo(_ size: CGSize) -> UIImage? { | |
UIGraphicsBeginImageContext(size) | |
draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height)) | |
let image = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return image | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment