Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Use original image instead of re-encoding as max quality JPEG #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

orand
Copy link

@orand orand commented May 29, 2014

MediaPicker was using UIImage.AsJPEG() to save the image picked from the camera roll. This re-encodes the image with maximum JPEG quality, resulting in an approximate doubling of the file size and loss of the original EXIF data.

This PR makes an exact copy of the original file from the asset library unless an edited version of the image exists, in which case it still uses UIImage.AsJPEG() since that is the only way to get the edited version of the image data.

I have tested and confirmed that this fix preserves the original file size and EXIF data for unedited images.

@orand
Copy link
Author

orand commented May 30, 2014

Ooops! Please do not merge this PR yet! While it fixes taking pictures from the camera roll, it breaks taking pictures directly from the camera, which I wasn't able to test in the simulator. I'll be back with a fix.

@orand
Copy link
Author

orand commented Jun 4, 2014

This was quite a bit more work than I expected, but this is now working correctly based on extensive testing on a real device. In addition to the original image file fix described above, I added better support for picking an image directly from the camera which previously always saved with maximum compression by calling AsJPEG() and tossed the original EXIF data. Now it adds the original EXIF data to the saved image and uses the compression quality you optionally provide with StoreCameraMediaOptions.JpegCompressionQuality which defaults to the compression quality used by the Camera app which results in a quality of 96 according to ImageMagick. This results in files that are 2x to 3x smaller than 100% quality.

@orand orand force-pushed the OriginalImageFix branch from c3b3bae to 766bba7 Compare July 30, 2015 22:09
…re-encoding

save images with original EXIF and configurable compression when picking directly from the camera or picking an edited image
@orand orand force-pushed the OriginalImageFix branch from 766bba7 to b128dfe Compare July 30, 2015 22:49
@orand
Copy link
Author

orand commented Jul 30, 2015

Updated the PR to add support for Unified API

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant