apache / apache/cordova-plugin-camera
Android: encodingType is not ignored when sourceType is set with PHOTOLIBRARY or SAVEDPHOTOALBUM
- Dominant language
- Objective-C
- Stars
- 976
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
As per documentation: https://cordova.apache.org/docs/en/10.x/reference/cordova-plugin-camera/#cameraoptions-errata
"encodingType" should be ignored when source type is PHOTOLIBRARY or SAVEDPHOTOALBUM. How ever when "encodingType" is set with "Camera.EncodingType.JPEG" and selecting a png picture from album results in unecessary transformation and is not as per the documentation

The reason seems to be unnecessary check for mime type of the choosen file to match the encodingType in options and when not matched it does the transformation:
https://github.com/apache/cordova-plugin-camera/blob/ed216ce7148b97ad23316f0530cd9abc2d8d6562/src/android/CameraLauncher.java#L729
Is this a bug or a known behavior? Atleast there is difference in documentation and implementation and there is no option to avoid transformation with out providing the same encoding type which is not possible to provide before hand
Contributor guide
Research direction
Start in src/android/CameraLauncher.java at the check around line 729, then compare it with the camera options errata for PHOTOLIBRARY and SAVEDPHOTOALBUM. Reproduce the case using a PNG album image with encodingType set to JPEG. Done means the implementation matches the documented behavior and the regression is verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100