Cross-Platform Support for Saving Images in JPG Format in .NET MAUI #31657
Replies: 2 comments
-
|
Talking to CoPilot AI, you could implement your reusable cross‑platform image saver service. Each platform would threat .jpg/.jpeg file extension properly. Learned from CoPilot AI, it's not an MAUI bug, it's an OS specific working you can cover making. I copied your content to CoPilot AI and got reusable cross‑platform image saver service. |
Beta Was this translation helpful? Give feedback.
-
|
I just did recent project (just Android/iOS only) where we were pulling images from the Camera and downsizing/compressing them to target max file size and saving out to jpg for submission to backend API. Not sure if this helps - but this is what I discovered :
It sounds weird the file extension for jpeg is making so much difference here - typically the other tooling is primarily looking at the header of the output file - surprised it doesn't work with either extension as both are commonly used. We did use '.jpg' instead of '.jpeg' but I'm not convinced this would cause the issues. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am developing an image-saving feature in a .NET MAUI application and am seeking guidance on ensuring consistent, cross-platform behavior.
The goal is to allow users to save images in the following formats:
.png).jpeg).bmp).jpegfor JPEG-encoded images)While PNG, JPEG, and BMP are mostly supported across platforms, adding support for
.jpgextension has revealed inconsistent behavior across platforms.Current Implementation Status:
Windows:
.png,.jpeg,.bmp, and.jpgby providing the format as a string..jpgand.jpegfiles have identical sizes (e.g., both 300 KB). However, unclear whether this behavior is correct.Android:
Bitmap.CompressFormat.JPEG, Android'sMediaStoreautomatically assigns a.jpgextension based on theimage/jpegMIME type, regardless of whether.jpegwas specified in the filename..iOS/MacCatalyst:
UIImage.AsJPEG()andUIImage.AsPNG()work reliably for saving files with.jpegand.pngextensions..jpgextension results in:.pngextension or not recognized)..jpegand.pngextensions seem to work reliably.Questions:
.jpgextension on all platforms, especially iOS?UIImageor the underlying OS, where it strictly prefers the.jpegextension?MediaStore's default behavior to enforce a user-specified extension, or should we align with the platform's convention and always use.jpg?.jpgbe treated as an alias for .jpeg within the application's logic, with platform-specific code to handle the final file extension, or is there a more unified approach?Any insights, workarounds, or roadmap updates would be greatly appreciated. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions