Skip to content

Instantly share code, notes, and snippets.

@m25lazi
Created August 5, 2017 06:46
Show Gist options
  • Save m25lazi/820cab17b1748b18faa96f9e4d9fd5c6 to your computer and use it in GitHub Desktop.
Save m25lazi/820cab17b1748b18faa96f9e4d9fd5c6 to your computer and use it in GitHub Desktop.
UIImage extension for using in Inception
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