iOS UIImagePickerController result image orientation after upload

后端 未结 20 1949
长发绾君心
长发绾君心 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:22

    I have experienced this issue with images taken from camera or saved in camera roll which are taken from camera. Images downloaded in photo library from safari browser does not rotate when uploaded.

    I was able to solve this issue by making the image data as JPEG before uploading.

    let image = info[UIImagePickerControllerOriginalImage] as! UIImage        
    let data = UIImageJPEGRepresentation(image, 1.0)
    

    We can now use the data for uploading and the image will not get rotated after upload.

    Hope this will work.

提交回复
热议问题