Capacitor Camera.getPhoto Transparent Images

Hey forum! First post so don’t slaughter me plz :blush:

Anyways, I am trying to accept photos with transparent backgrounds on iOS using Camera.getPhoto but have been unable to configure it to do that correctly.

Did I miss something or is this a current limitation? (If so, can you suggest a work-a-round plz?)

Cheers

As a temporary workaround I’ve just used <input type="file"> and am processing the file using Javascript and the blueimp-load-image package.

Any new info on this? Trying to get .png file with Camera.getPhoto and it’s only jpeg

I saw it’s what is also stated in the docs but some more info on how to work around that or if it’s gonna be available will be really useful

When I use the term “work around”, I mean “something that I can do in my code to change how somebody else’s code behaves”.

I also think I can provide more useful assistance the better I understand what somebody’s ultimate goal is, as opposed to what they consider their proximate goal.

Your proximate goal is that you want PNG. I want to know why.

Because if the answer is something like “because PNG is lossless, JPEG is lossy, and I don’t want lossy”, I would urge rethinking the situation. Cellphone cameras these days provide extremely high resolution images, and the compression system used by JPEG is specifically designed to provide optimal performance for typical photos. It’s faster, it’s easier to deploy hardware acceleration, and it makes for smaller files that reduce stress on many chokepoints in your app. Additionally, once something has been compressed as JPEG (which, as I understand it, is true of every photo taken with Android or iOS), you’re not going to get any higher image quality than what is initially provided.

The only other reason that comes to mind is “I have an image manipulation library that works with PNG but not JPEG” (which would surprise me). If that is indeed the case, then you could transcode in your app.

As for “if it’s gonna be available”, I don’t think that’s an Ionic question, but rather a Google/Apple question, because the underlying limitation comes from the OS.

Hey rapropos, thank you for the answer!

So I’m probably understanding something incorrectly. My goal is this:
I’m getting files into my app using Camera.getPhoto both with using the camera and just for using the gallery for convenient access to local user files. But when the user selects these files using Camera.getPhoto and they turn into .jpeg, I lose their transparency, which was unexpected for me and I’m searching for solutions. (what was previously transparent background is now a black background)

From your answer I understand that this is OS limitation ?

That’s my understanding. At least in Capacitor 2, if you look at either the iOS source or the Android source, JPEG is hardcoded everywhere.

Oh my. I guess I need to find another way to browse files then.

Thanks for answering and have a good day!

did you find any solution ?