2014-12-12 20:29:17 +00:00
|
|
|
extension UIImage {
|
|
|
|
func resize(size: CGSize) -> UIImage {
|
|
|
|
UIGraphicsBeginImageContext(size)
|
|
|
|
self.drawInRect(CGRectMake(0, 0, size.width, size.height))
|
|
|
|
let newImage = UIGraphicsGetImageFromCurrentImageContext()
|
|
|
|
UIGraphicsEndImageContext()
|
|
|
|
return newImage
|
|
|
|
}
|
|
|
|
|
|
|
|
class func imageWithData(data: NSData, size: CGSize) -> UIImage? {
|
|
|
|
return UIImage(data: data)?.resize(size)
|
|
|
|
}
|
2014-12-12 21:49:22 +00:00
|
|
|
|
2014-12-12 20:29:17 +00:00
|
|
|
class func sizeForImageData(data: NSData) -> CGSize? {
|
|
|
|
return UIImage(data: data)?.size
|
|
|
|
}
|
|
|
|
}
|