Skip to content

Fix 5144 HEIC files#6758

Open
Lou0320 wants to merge 4 commits intocommons-app:mainfrom
Lou0320:fix-6651-unsupported-filetypes
Open

Fix 5144 HEIC files#6758
Lou0320 wants to merge 4 commits intocommons-app:mainfrom
Lou0320:fix-6651-unsupported-filetypes

Conversation

@Lou0320
Copy link

@Lou0320 Lou0320 commented Mar 18, 2026

Description (required)

Fixes #5144

1) What changes did you make and why?

First I added support for HEIC/HEIF images by converting them to JPG before upload.
Then I added the HEIC/HEIF type to the list of accepted file types.
At first I implemented a pop up message to say that a conversion has been made.
But instead of showing a separate pop-up message, I decided to add the conversion note to the “Potential problems with this image” section during upload:

"
Problems found in this image
Potential problems with this image:

  • The image type previously selected was not supported and has been converted to JPG.
  • [Other potential problem messages that can usually appear…]

Do you still want to upload this picture ?

[cancel] | [upload]
"
(see image bellow)

For those changes I implemented two functions in FilePicker:

convertHeicToJpg(file: File, context: Context): File — converts a HEIC file to JPG using ImageDecoder for Android P+ devices.

handleHeicFile(file: UploadableFile, activity: Activity): UploadableFile — checks if a file is HEIC/HEIF and converts it, marking it as hasUnsupportedFormat for display in the potential problems list.

At first i was working on another issue so I hope the solutions brought were relevant to this issue.

2) Tests performed (required)

Tested ProdDebug build on Pixel 6 emulator with API level 33.
(I had to make some research here because I wasn't sure how to test everything efficiently).

I verified if HEIC and HEIF images are correctly converted to JPG. If converted images are flagged in the “Potential problems” list. And if other accepted formats continue to work as expected.

3) Screenshots (for UI changes only)

We can now select HEIC :
75570
(exemple of an image of a street in Paris I took for tests)

We can see the problem/warning message for conversion :
75552

We can upload HEIC with successfull conversion to jpg :
75566
75557


@neeldoshii
Copy link
Collaborator

@Kota-Jagadeesh Can you check does the image retain exif data if we convert HEIC image to jpg?

val source = ImageDecoder.createSource(context.contentResolver, Uri.fromFile(file))
ImageDecoder.decodeBitmap(source)
} else {
throw IllegalStateException("HEIC conversion requires Android P+")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw IllegalStateException("HEIC conversion requires Android P+")

meaning? for older versions below the android 9 what will happen? It doesn't make sense to have throw method. Can you check once? @Lou0320

@github-actions
Copy link

✅ Generated APK variants!

@Lou0320
Copy link
Author

Lou0320 commented Mar 19, 2026

Yes of course ! I just realized why this could be a problem. Since I saw that the general use of HEIC files are on Adnroid 9+ and ImageDecoder requires Android 9+ I enforced it. I can see why now making it crash is definitely not a good solution, I didn't think it could affect any users but the users with images they downloaded (such as test ones for us) can try to upload HEIC files on an older Android version. I am thinking about maybe telling the user that are on Android 8 or less that HEIC files are not supported on their Android version. Should I implement this instead ?
@neeldoshii

@Lou0320
Copy link
Author

Lou0320 commented Mar 19, 2026

I apologize if my work is a bit messy I tried to do with what i found on how to manage HEIC files through research, it's my first time contributing but I am happy to learn more. If you have any advice on maybe something else I could use instead of ImageDecoder I am open to learn more about it !

Copy link
Collaborator

@Kota-Jagadeesh Kota-Jagadeesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kota-Jagadeesh Can you check does the image retain exif data if we convert HEIC image to jpg?

Nope, @neeldoshii. I uploaded the HEIC image and it converted to JPG as expected, but the converted JPG couldn’t retain the EXIF data.

EDIT : isn’t this issue related to #6659? or are we expecting the converted JPG to preserve the original EXIF data, even though the image itself isn’t modified?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support HEIF, HEIC upload

3 participants