Skip to content

Fix 5144 HEIC files#6758

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

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

Conversation

@Lou0320
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

✅ Generated APK variants!

@Lou0320
Copy link
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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
Copy Markdown
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?

@nicolas-raoul
Copy link
Copy Markdown
Member

Sounds great generally, thanks Lou0320!

"telling the user that are on Android 8 or less that HEIC files are not supported on their Android version"

Good solution, yes.

When converting HEIC to JPG we need to retain the EXIF. Does that look doable?

@Lou0320
Copy link
Copy Markdown
Contributor Author

Lou0320 commented Mar 22, 2026

@nicolas-raoul Okay I will implement that ! And for the EXIF I think there is a way to do it, I will look into it and try to implement it.

@Lou0320
Copy link
Copy Markdown
Contributor Author

Lou0320 commented Mar 31, 2026

@nicolas-raoul Sorry to bother you, I have been trying to test my code but when I build from Android Studio it does launch the app on my phone but impossible to log in. When I try to do anything about creating an account or resetting my password (I already have an account) it says "Error Requests from your IP have been blocked, please see [link] for more information.
I understood my ip adress got blocked because of an automatic protection against bots but to get through this I need to have an LDAP Account (IDP) or a MediaWiki which I do not I think and can't seem to find how to create one. I saw that this problem happens often but I am not sure how to fix it. I thought it was because my code broke something in the app at first.

@Kota-Jagadeesh
Copy link
Copy Markdown
Collaborator

@Lou0320 Did you try logging into the app using the ProDebug flavor?

@nicolas-raoul
Copy link
Copy Markdown
Member

Yes try prodDebug. What is your prod wiki username?

@Lou0320
Copy link
Copy Markdown
Contributor Author

Lou0320 commented Mar 31, 2026

ok I'm not sure how to use prodDebug anymore but I will try, my username is Loulou0320.

@Kota-Jagadeesh
Copy link
Copy Markdown
Collaborator

ok I'm not sure how to use prodDebug anymore

In the android studio, Go to main menu -> build -> select build variant -> Prodebug

@Lou0320
Copy link
Copy Markdown
Contributor Author

Lou0320 commented Mar 31, 2026

for some reason even if I am in my branch i can't seem to open the app like I did before to see my own changes even if I'm in the right branch and in proDebug build. All the tests pass with the changes that I added, would it be okay for me to push my changes ?

@nicolas-raoul
Copy link
Copy Markdown
Member

would it be okay for me to push my changes ?

Sure, feel free to push at any time. :-)

@RitikaPahwa4444
Copy link
Copy Markdown
Collaborator

The other PR has been merged, are we good to close this one @Lou0320? Thanks a lot for such a valuable contribution!

@Lou0320
Copy link
Copy Markdown
Contributor Author

Lou0320 commented Apr 13, 2026

@RitikaPahwa4444 Thank you for letting me work on this issue and yes we can close this one !

@Lou0320 Lou0320 closed this Apr 13, 2026
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

5 participants