Capture Image Orientation

Jason, thank you very much! This almost works a treat! You do need to change a few iosViews as well and I don’t think the editedImage needs to change, but the image comes across perfect! The only snag is even though the PicturePickerController.sourceType is set to UIKit.UIImagePickerController.Source.Camera, it brings you to the photo library and I can’t get it to use the Camera

Chris check the Source enumeration in the UIImagePickerController and make sure that Camera = 1 and PhotoLibrary = 0.

Public Enum Source
Camera = 1
PhotoLibrary = 0
SavedPhotoAlbum = 2
End Enum

Thanks Jason - Ya, that’s what they’re set to…

Jason this is the sample project I’m using to test your code:

Download Take Photo

Thanks for any help

Chris I haven’t had a chance to compare the code to work out what might be different, but just check that you’re using a real device as the iOS Simulator doesn’t support the camera.

Thanks Jason. I appreciate that. Yes, I’m trying it on an iPhone. Thanks very much for the time you’ve already offered.

If anyone else want’s to check the code and has the time, I’d really appreciate it. It works perfect except it’s calling the photo library and not the camera. It’s basically iOSkit with the small change Jason suggested to changing originalImage to a picture and Jason’s code.

Thanks for any help

Chris I notice in the test project you are missing the camera capability setting. It might be the case that the UIImagePickerController defaults to the photo library if it can’t request camera permissions from the user.

To add this, click on iOS within Build Settings, then click on the gear icon and switch on “Camera Access”. You might also need to click on Options and enter an explanation for the plist which will be displayed for the user when they first launch the camera and grant permission.

Hi Jason. Thanks very much for looking at this, but alas, it’s not the answer. I had tried it in the past, but set it back to default as it had no effect. Funnily enough, using the MobileImagePicker doesn’t seem to require Camera Access switched ON…

Hi,

I’m just reaching out to the Community again, hoping someone in the know has a few minutes to spare to have a look this project :

Download TakePhoto Project

to see why the Photo Library is called instead of the Camera.

Chris

I appreciate any help at all to point me in the right direction

Hi. Reaching out again, hoping someone can help - Is there anyone available within Xojo that might be able to help me get around one of their bugs?

Thanks

Did you add the key NSCameraUsageDescription in your Info.plist?
It’s required for camera access. (could be done using the switch on, make sure you set a good message in the “Options…”)

Thanks DerkJ. Ya, I do. I have it in the Info and I’ve tried turning ON ‘Camera Access’ capabilities in the project with ‘Uses your Camera to scan barcodes and take photographs’ in the Options.

When PicturePickerController.PresentInView is called, it still behaves as if PicturePickerController.sourceType is set to UIKit.UIImagePickerController.Source.PhotoLibrary, rather than UIKit.UIImagePickerController.Source.Camera

why not use:

https://documentation.xojo.com/api/user_interface/mobile/mobileimagepicker.html

Because there is a longterm bug in this control which is unaware of the camera orientation and distorts the image unless the iPhone is only in landscape position

Note image picker only works in portrait mode as far as i know.
Other camera options you can check the FB requests and add a thumbs up. :+1: