How to generate an UIImage from AVCapturePhoto with correct orientation?

后端 未结 5 932
清酒与你
清酒与你 2020-12-28 15:29

I am calling AVFoundation\'s delegate method to handle a photo capture, but I am having difficulty converting the AVCapturePhoto it generates into

5条回答
  •  清酒与你
    2020-12-28 16:10

    Inside the AVCapturePhoto I’m pretty sure you will find a metadata object of the also called CGImageProperties.
    Inside it you will find the EXIF dictionary for orientation the next step is just to take the orientation and create an image according to that.
    I do not have experiences in using AVCapturePhotoOutput but I have some using the old way.
    Pay attention that the EXIF dictionary is mapped differently in UIImageOrientation.
    Here is an article I wrote a lot of time ago, but the main principle are still valid.
    This question will point you to some implementations, it's pretty old too, I'm pretty sure that in the latest version they released easier API, but it will still guide you into take the issue.

提交回复
热议问题