Skip to content

Instantly share code, notes, and snippets.

@chriswebb09
Created May 11, 2017 15:22
Show Gist options
  • Save chriswebb09/51dd6f00a571bea175c89ee807648bbe to your computer and use it in GitHub Desktop.
Save chriswebb09/51dd6f00a571bea175c89ee807648bbe to your computer and use it in GitHub Desktop.
extension UIImage {
enum Quality: CGFloat {
case worst = 0
case low = 0.25
case medium = 0.5
case high = 0.75
case best = 1
}
var png: Data? { return UIImagePNGRepresentation(self) }
func jpeg(_ quality: Quality) -> Data? {
return UIImageJPEGRepresentation(self, quality.rawValue)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment