Plugin.Maui.Exif
provides the ability to read EXIF metadata from image files in your .NET MAUI application across iOS, Android, and Windows platforms.
Learn more about this plugin in this video.
- Read EXIF metadata from image files and streams
- Write EXIF metadata to image files and streams
- Extract common metadata like camera make/model, date taken, GPS coordinates, camera settings
- Cross-platform support (iOS, macOS Catalyst, Android, Windows)
- Easy-to-use API with both static and dependency injection patterns
- Extension methods for common EXIF data operations
<PackageReference Include="Plugin.Maui.Exif" Version="1.0.0" />
// Using the static API
var exifData = await Exif.Default.ReadFromFileAsync(imagePath);
// Using dependency injection
builder.Services.AddSingleton<IExif>(Exif.Default);
// In your class
public MainPage(IExif exif)
{
var exifData = await exif.ReadFromFileAsync(imagePath);
}
var exifData = await Exif.Default.ReadFromFileAsync("path/to/image.jpg");
if (exifData != null)
{
// Basic image info
Console.WriteLine($"Camera: {exifData.Make} {exifData.Model}");
Console.WriteLine($"Date taken: {exifData.DateTaken}");
Console.WriteLine($"Dimensions: {exifData.Width}x{exifData.Height}");
// Camera settings
Console.WriteLine($"F-number: f/{exifData.FNumber}");
Console.WriteLine($"Exposure time: {exifData.ExposureTime}s");
Console.WriteLine($"ISO: {exifData.Iso}");
Console.WriteLine($"Focal length: {exifData.FocalLength}mm");
// GPS coordinates
if (exifData.HasGpsCoordinates())
{
Console.WriteLine($"Location: {exifData.Latitude}, {exifData.Longitude}");
Console.WriteLine($"Altitude: {exifData.Altitude}m");
}
}
using var stream = File.OpenRead("path/to/image.jpg");
var exifData = await Exif.Default.ReadFromStreamAsync(stream);
// Create or modify EXIF data
var exifData = new ExifData
{
Make = "Canon",
Model = "EOS R5",
DateTaken = DateTime.Now,
Artist = "John Doe",
Copyright = "© 2024 John Doe",
Latitude = 37.7749,
Longitude = -122.4194
};
// Write to file
var success = await Exif.Default.WriteToFileAsync("path/to/image.jpg", exifData);
// Write to stream
using var inputStream = File.OpenRead("input.jpg");
using var outputStream = File.Create("output.jpg");
var success = await Exif.Default.WriteToStreamAsync(inputStream, outputStream, exifData);
// Read existing EXIF data and modify it using extension methods
var originalExifData = await Exif.Default.ReadFromFileAsync("path/to/image.jpg");
if (originalExifData != null)
{
var updatedExifData = originalExifData
.WithCameraInfo("Canon", "EOS R5")
.WithGpsCoordinates(37.7749, -122.4194)
.WithMetadata("John Doe", "© 2024 John Doe", "Beautiful sunset")
.WithDateTaken(DateTime.Now);
await Exif.Default.WriteToFileAsync("path/to/image.jpg", updatedExifData);
}
// Remove GPS coordinates for privacy
var exifWithoutGps = originalExifData?.WithoutGpsCoordinates();
if (exifWithoutGps != null)
{
await Exif.Default.WriteToFileAsync("path/to/image.jpg", exifWithoutGps);
}
The plugin includes useful extension methods:
// Check if GPS coordinates are available
if (exifData.HasGpsCoordinates())
{
// Get formatted GPS string
var coordinates = exifData.GetFormattedGpsCoordinates();
// Result: "37.421998°N, 122.084000°W"
}
// Get formatted camera settings
var settings = exifData.GetFormattedCameraSettings();
// Result: "f/2.2, 1/120s, ISO 100, 24mm"
// Get camera information
var camera = exifData.GetCameraInfo();
// Result: "Apple iPhone 12 Pro"
// Check if image needs rotation
if (exifData.NeedsRotation())
{
var angle = exifData.GetRotationAngle();
// Rotate the image by the returned angle
}
Width
/Height
- Image dimensionsOrientation
- Image orientationDateTaken
- Date and time the photo was taken
Make
- Camera manufacturerModel
- Camera modelSoftware
- Software used to process the image
FNumber
- Aperture f-numberExposureTime
- Shutter speed in secondsIso
- ISO sensitivityFocalLength
- Focal length in millimetersFlash
- Flash mode used
Latitude
- GPS latitudeLongitude
- GPS longitudeAltitude
- GPS altitude in meters
Copyright
- Copyright informationArtist
- Photographer/artist nameImageDescription
- Image description or commentAllTags
- Dictionary containing all available EXIF tags
Platform | Supported | Implementation |
---|---|---|
iOS | ✅ | ImageIO Framework |
macOS Catalyst | ✅ | ImageIO Framework |
Android | ✅ | AndroidX ExifInterface |
Windows | ✅ | Windows Runtime BitmapDecoder |
Add the following permissions to your AndroidManifest.xml
:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
Note
When using MediaPicker.PickPhotoAsync()
, the selected image may not include GPS EXIF data due to Android privacy restrictions (API 29+).
To access GPS metadata in this case, you must declare and request the ACCESS_MEDIA_LOCATION
runtime permission.
When using MediaPicker.CapturePhotoAsync()
, the GPS data may be missing unless your app has location permissions (ACCESS_FINE_LOCATION
or ACCESS_COARSE_LOCATION
) and the selected camera app supports embedding location info.
Note that the camera app behavior varies across devices and cannot be controlled by your app.
No special permissions required for reading EXIF data from files accessible to your app.
No special permissions required.
The repository includes a sample app demonstrating how to:
- Select images using FilePicker
- Read and display EXIF metadata
- Write and modify EXIF metadata
- Show formatted camera settings and GPS information
- Display all available EXIF tags
- Additional metadata formats support
- Batch processing capabilities
- Advanced EXIF tag manipulation
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.