-
-
Notifications
You must be signed in to change notification settings - Fork 362
Png image is being converted to jpg when selected from gallery in case of iOS #264
Comments
I think iOS store images in gallery as .jpg by default, try to take a photo with the camera an you will see is a .jpg |
Everything is stored as jpg by design |
@jamesmontemagno I just had a case where a customer added a PNG file to the gallery and when getting it back it lost transparency because it was returned as a jpg. However I was able to have them workaround this issue by creating their own dependency service, checking the path of the image returned from the iOS Our guide for a Forms pick photo dependency service does the same thing: See this code:
The above forces the image to be returned to the caller as a JPG, but if you do this:
Then you get a PNG back. There would seem to be no reason why you can't do similar in this library. I will work on a pull request. |
Fixes issue jamesmontemagno#264 Png image is being converted to jpg when selected from gallery in case of iOS - Checks for the file extension when first getting the photo info after user picks it - Sets a Static variable, photoType, with “png” or “jpg” depending on photo type retrieved from Photos app. - Uses that static variable, photoType, to determine the photo type to save and return. - This preserves any png transparency that may have been in the PNG file saved in the photos app.
Yes, if you take a picture, it will store as a JPEG, but there are other ways to get images into the Photos app, like saving a PNG image from a website for one. I just did a pull request that should fix this issue. It checks the file extension of the selected image, and if a PNG saves it and passes it back as a PNG instead of a JPG. |
If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.
Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.
Bug Information
Version Number of Plugin: 2.6.2
Device Tested On: Any iOS Device
Simulator Tested On: Any iOS Simulator
Version of VS: Testing it on Mac Mini
Version of Xamarin: 2.3.3.193
Versions of other things you are using: -
Steps to reproduce the Behavior
Just select a png photo from gallery using following code snippet
Expected Behavior
Image should be png and file path should end with .png
Actual Behavior
Image is jpg and filepath is ending with .jpg
Code snippet
Screenshotst
The text was updated successfully, but these errors were encountered: