Posts

Post marked as solved
4 Replies
3.4k Views
HiI'm using Swift 4 and the AvCam example code from Apple. In my own app I've an issue where the captured image orientation is wrong. My requirement is to save the photos to my applications folder as opposed to the Photos library. I've spent a day trying to correct my own code and got nowhere.As a test I modified the AvCam code to write the photo data to a static variable in a struct and then display that image on the camera view in AvCam by tapping a button as follows:// In the camera view controller: @IBOutlet weak var pv: UIImageView! // for previewing test @IBAction func btn(_ sender: UIButton) { // for setting preview test image let dataProvider = CGDataProvider(data: photoTest.photo! as CFData) let cgImageRef: CGImage! = CGImage(jpegDataProviderSource: dataProvider!, decode: nil, shouldInterpolate: true, intent: .defaultIntent) let photo = UIImage(cgImage: cgImageRef) pv.contentMode = .scaleAspectFill pv.image = photo }The orientaion issue is replicated in AvCam with the above code. In my own app the image is previewed before saving to the apps folder and the images orientation is always wrong in the preview as well as when reloading the image from disk. I.e. if the iphone is in portrait orientation, the preview image is rotated 90 degrees anti-clockwise, in landscape the same happens so the preview image appears to be the correct way up.I'm assuming I've completely missed the point somewhere along the line as it seems to me that regardless of device orientation, the top of a photo should always be the top. For example, in the Photos app photos are shown the correct way up regardless of orientation.Any help would be much appreciated, this is driving me nuts ;o)Cheers
Posted
by Mark6519.
Last updated
.