The image comes from UIImagePickerViewController
:
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
print("1: \(image)")
if let data = UIImagePNGRepresentation(image) {
print("2: \(UIImage(data: data))")
}
}
}
The result is following:
1: size {3024, 4032} orientation 3 scale 1.000000
2: Optional( size {4032, 3024} orientation 0 scale 1.000000)
Why UIImagePNGRepresentation()
changes orientation of the image? How to prevent from this?