Getting a Properly Rotated UIImage from AVCaptureSession

Recently I started work on a custom camera for You Doodle. As part of this, I was overhauling the camera picker, moving away from UIImagePickerController to my own custom camera. This required diving into AVFoundation. While I have a lot of experience with this framework, one piece took much longer than expected – rotating the final image to an ‘up’ orientation with a proper width and height value.

After several hours of hair pulling I finally conjured up this function:

 

May it serve you well if you are in the bowels of AVFoundation 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

*