iOS Question HEIF - high efficiency image file format - on iPhones

JackKirk

Well-Known Member
Licensed User
Longtime User
My iOS app just got bitten.

The tester has an iPhone 11 Pro and when he took a selfie for the app to upload the app just hangs.

After some investigation it appears he was taking the selfie in HEIF - if he manually changed the camera format setting from "High Efficiency" to "Most Compatible" everything worked as normal.

I could not find any reference to HEIF or "high efficiency" in the forums.

This would appear to be an emerging issue in iOS (and probably Android with time), refer:

https://forums.macrumors.com/threads/high-efficiency-vs-most-compatible.2201340/
https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format

Questions:
  1. Is there any info on this in the forums?
  2. How to detect what the iPhones camera setting is?
  3. How to convert from HEIF to jpg?
 
Last edited:

JackKirk

Well-Known Member
Licensed User
Longtime User
Can you post the relevant code that fails? Are you using the Camera object? How are you serializing the image?
Hi Erel,

It doesn't appear to be a failure - the app literally hangs - holds the screen and just sits there.

I don't have an iPhone 11 available but a bit of further research suggests it ("High Efficiency" / "Most Compatible") has been available since iOS 11.

Tomorrow I'm going to try to use the AWS Device Farm and test an iPhone X (AWS Device Farm does not have an iPhone 11 in "remote mode").

I have an idea of how to tell if the data stream returned by LLCamera is jpg or HEIC

That is assuming that LLCamera is actually returning HEIC - which I won't be able to tell until tomorrow.

If LLCamera is returning HEIC and I can work out if it is HEIC or jpg then I would need to be able to convert HEIC to jpg.

Would it be possible for you to look at this (i.e answer my question 3 in first post)?

Regards...
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Load the bitmap with Bitmap.Initialize2 and save it with Bitmap.WriteToStream with the last parameter set to "JPEG"
On looking closely at the code it uses LLCamera to take a photo - which gets returned as a bitmap - so shouldn't be affected by "High Efficiency" - or is it.

I have been testing my app on AWS Device Farm using an iPhone X (iOS 12) and iPhone 11 Pro Max (iOS 13.1.3)

It worked fine on both - I also tested a rigged version of the app to log some details of the image produced - indicated a proper bitmap was produced on both camera format settings on both phones.

So I got in touch with my tester (actually my son in law who works in IT and is no dope) and got him to test again - still fails when on camera format "High Efficiency" but works with "Most Compatible" (his iPhone is iOS 13.3).

When the app fails it generates a low level log which is posted to an AWS S3 bucket - see attachment for what my son in law produced.

This is indicating "The network connection was lost." - which occurs in a step subsequent to the image processing stuff where I am uploading the photo to an AWS S3 bucket.

I'm stumped!
I can test it with an iPhone 11.
I may have to take you up on this.

If you could give me an email address, I can send you a digital ticket which will give you access to the App Store version of the app.
 

Attachments

  • 160659.txt
    898 bytes · Views: 165
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
i_view64_5tf7OX07AK.png


Tested on iPhone 11.
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Erel, thanks for that.

The image has ended up in AWS as 2160 x 3840 pixels and about 3MB - which is weird because my son in law's was 3240 x 5760 and over 11MB.

What exact phone did you use?

What is the iOS level?

It looks like you used the camera on the rear of the phone - correct?

Did you have the cameras format set to "High Efficiency"?

Did you have any camera options set that could have affected the size?

Thanks...
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
If you are using LL_Camera then set the Preset to PRESET_1920x1080 and it will not take a 12mb image.
Erel, this is not a good solution.

The image in question is the customer's "master face" used by the AWS Rekognition service to determine what photos and videos he is in.

Consequently it should be of the highest possible quality/resolution - up to 5 megapixels (a Rekognition limit).

I have been using PRESET_HIGH then scaling to not exceed this limit.

In the last couple of hours I have realised that I was not scaling correctly - didn't understand the scaling implications of canvas.CreateBitmap

I was actually making the images 4 x as many pixels as they should be - and this has only just blown up because I had never used a 12 megapixel camera before.

All is now sorted and once again I am indebted to your help...
 
Upvote 0
Top