iOS UIImagePickerController result image orientation after upload

后端 未结 20 1973
长发绾君心
长发绾君心 2020-11-22 00:44

I am testing my iPhone application on an iOS 3.1.3 iPhone. I am selecting/capturing an image using a UIImagePickerController:

UIImagePickerCont         


        
20条回答
  •  时光说笑
    2020-11-22 01:24

    Here is the Swift-4.2 code for automatic fix your image orientation Returns UIImage

    func AutofixImageOrientation(_ image: UIImage)->UIImage {
    
        UIGraphicsBeginImageContext(image.size)
    
        image.draw(at: .zero)
    
        let newImage = UIGraphicsGetImageFromCurrentImageContext()
    
        UIGraphicsEndImageContext()
    
        return newImage ?? image
    }
    

提交回复
热议问题