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

Fixes issue #795 #918

Merged
merged 1 commit into from
Jan 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Media.Plugin/Android/MediaImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,8 @@ public Task<bool> FixOrientationAndResizeAsync(string filePath, StoreCameraMedia

//if we need to rotate then go for it.
//then compresse it if needed
var photoType = System.IO.Path.GetExtension(filePath)?.ToLower();
var compressFormat = photoType == ".png" ? Bitmap.CompressFormat.Png : Bitmap.CompressFormat.Jpeg;
if (rotation != 0)
{
var matrix = new Matrix();
Expand All @@ -743,7 +745,7 @@ public Task<bool> FixOrientationAndResizeAsync(string filePath, StoreCameraMedia
//always need to compress to save back to disk
using (var stream = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite))
{
rotatedImage.Compress(Bitmap.CompressFormat.Jpeg, mediaOptions.CompressionQuality, stream);
rotatedImage.Compress(compressFormat, mediaOptions.CompressionQuality, stream);
stream.Close();
}
rotatedImage.Recycle();
Expand All @@ -757,7 +759,7 @@ public Task<bool> FixOrientationAndResizeAsync(string filePath, StoreCameraMedia
//always need to compress to save back to disk
using (var stream = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite))
{
originalImage.Compress(Bitmap.CompressFormat.Jpeg, mediaOptions.CompressionQuality, stream);
originalImage.Compress(compressFormat, mediaOptions.CompressionQuality, stream);
stream.Close();
}
}
Expand Down