cordova-plugin-camera icon indicating copy to clipboard operation
cordova-plugin-camera copied to clipboard

PNG getting Converted to JPG when selecting Images from Gallery

Open yeshwanthsai1010 opened this issue 9 months ago • 4 comments

When using the Cordova Camera plugin with the encodingType option as JPEG,

I noticed that when selecting a PNG image from the gallery, the plugin modifies both the file name and type, converting the image to JPG if any scaling or modifications are applied.

Expected Behavior:

  • The file name may change due to processing, but the original image format (PNG) should be retained unless explicitly converted by the user.

Observed Behavior:

  • When a PNG image is selected, the plugin automatically converts it to JPG after applying modifications (e.g., scaling).
  • The encoding type seems to be applied regardless of the source image format, leading to unexpected format conversion.

Questions:

  • Is this the expected behavior?
  • Is there a specific reason for converting PNG images to JPG?
  • Can the plugin be modified to retain the original image format when selecting images from the gallery?

yeshwanthsai1010 avatar Mar 17 '25 12:03 yeshwanthsai1010

Are you observing this behaviour on both android and iOS?

Glancing over the android code base, it looks like there is an effort to maintain encoding by choosing PNG CompressFormat if encoding type is PNG. So if you're observing this on android, it may indicate a bug.

On iOS I'm not as familiar with the code base.

breautek avatar Mar 17 '25 19:03 breautek

@breautek Thank you for your quick response. Yes, I have observed this behavior on both Android and iOS. I understand that the file name might change due to processing, but the file extension changing along with it is an issue, as it alters the original image format unexpectedly

yeshwanthsai1010 avatar Mar 18 '25 05:03 yeshwanthsai1010

@breautek Hi, just checking in on this issue is it being considered a bug, and is there any plan to address it? Please let us know if any additional information is needed from our side. Thanks!

yeshwanthsai1010 avatar Apr 09 '25 07:04 yeshwanthsai1010

@breautek Hi, just checking in on this issue is it being considered a bug, and is there any plan to address it? Please let us know if any additional information is needed from our side. Thanks!

Apache is all volunteer driven. I marked this as needs triage/confirmation because based on the description it sounds like a legitimate bug. Having a sample reproduction app that can setup and reproduce the bug would be helpful to serve as a confirmation and a test case. From there, someone would have to take the initiative to debug the native code to determine why there is unexpected behaviour.

I personally don't really have any plans on addressing this issue myself in the foreseeable future. This isn't reflective of the state of the issue. I'm just currently onto other projects in my workplace that doesn't involve Cordova applications, so I can't really justify allocating work hours towards Cordova, or the camera plugin at this time.

breautek avatar Apr 09 '25 12:04 breautek