private func fixOrientation(image: UIImage) -> UIImage {
if image.imageOrientation == UIImage.Orientation.up {
return image
}
UIGraphicsBeginImageContextWithOptions(image.size, false, image.scale)
image.draw(in: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height))
let normalizedImage: UIImage = UIGraphicsGetImageFromCurrentImageContext() ?? UIImage()
UIGraphicsEndImageContext()
return normalizedImage
}
网友评论