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?
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 :

