Created
December 29, 2015 19:22
-
-
Save jplazcano87/ad13693ff2c0cfc74320 to your computer and use it in GitHub Desktop.
Compress image data swift
This file contains 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 { | |
var uncompressedPNGData: NSData { return UIImagePNGRepresentation(self)! } | |
var highestQualityJPEGNSData: NSData { return UIImageJPEGRepresentation(self, 1.0)! } | |
var highQualityJPEGNSData: NSData { return UIImageJPEGRepresentation(self, 0.75)! } | |
var mediumQualityJPEGNSData: NSData { return UIImageJPEGRepresentation(self, 0.5)! } | |
var lowQualityJPEGNSData: NSData { return UIImageJPEGRepresentation(self, 0.25)! } | |
var lowestQualityJPEGNSData:NSData { return UIImageJPEGRepresentation(self, 0.0)! } | |
} | |
//usage | |
let imageData = imagePassed.lowestQualityJPEGNSData |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment