References
Background
It seems UIImage orientation get wrong in some cases.
Solution
import UIKit extension UIImage { // Fix UIImage Orientation func fixOrientation() -> UIImage { if self.imageOrientation == .up { return self } UIGraphicsBeginImageContext(self.size) self.draw(at: .zero) let newImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return newImage! } }