Created
May 11, 2017 15:22
-
-
Save chriswebb09/51dd6f00a571bea175c89ee807648bbe to your computer and use it in GitHub Desktop.
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 { | |
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