Conversation
|
@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+") |
There was a problem hiding this comment.
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
|
✅ Generated APK variants! |
|
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 ? |
|
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 ! |
There was a problem hiding this comment.
@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?
|
Sounds great generally, thanks Lou0320!
Good solution, yes. When converting HEIC to JPG we need to retain the EXIF. Does that look doable? |
|
@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. |
|
@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. |
|
@Lou0320 Did you try logging into the app using the ProDebug flavor? |
|
Yes try prodDebug. What is your prod wiki username? |
|
ok I'm not sure how to use prodDebug anymore but I will try, my username is Loulou0320. |
In the android studio, Go to main menu -> build -> select build variant -> Prodebug |
|
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 ? |
Sure, feel free to push at any time. :-) |
|
The other PR has been merged, are we good to close this one @Lou0320? Thanks a lot for such a valuable contribution! |
|
@RitikaPahwa4444 Thank you for letting me work on this issue and yes we can close this one ! |
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:
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 :

(exemple of an image of a street in Paris I took for tests)
We can see the problem/warning message for conversion :

We can upload HEIC with successfull conversion to jpg :

