Following:
extension UIImage {
var data: Data? { return UIImagePNGRepresentation(self) }
var highestQualityJPEGData: Data? { return UIImageJPEGRepresentation(self, 1.0) }
var highQualityJPEGData: Data? { return UIImageJPEGRepresentation(self, 0.75) }
var mediumQualityJPEGData: Data? { return UIImageJPEGRepresentation(self, 0.5) }
var lowQualityJPEGData: Data? { return UIImageJPEGRepresentation(self, 0.25) }
var lowestQualityJPEGData: Data? { return UIImageJPEGRepresentation(self, 0.0) }
}
Time is your!!!
yourImage.data
yourImage.highestQualityJPEGData