rodrigo alvesMar 19Unlisted
Preserving portrait orientation of UIImage saved as NSData
iOS developers often represent image in models as NSData objects, via UIImagePNGRepresentation. When trying to preserve images in portrait mode, we may run into troubles.
item.picture = UIImagePNGRepresentation(self.imageView.image)
UIImage(data: item.picture) // works, but no portrait orientation
We can solve this elegantly by extending UIImage, like this