UWP: How to take photo with all metadata using MediaCapture?

256 Views Asked by At

now i take photo using MediaCapture.CapturePhotoToStorageFileAsync but i got no exif metadata in it. I try using SoftwareBitnmap class, but got only BitmapPropertySet with manufacturer and model data only.

I need all metadata that device can support, like making photo with windows 10 build in Camera app.

1

There are 1 best solutions below

0
On

To get the image-specific properties, you need to call GetImagePropertiesAsync. The returned ImageProperties object exposes members that contain basic image metadata fields.

If you want to access a larger set of file metadata, you need to use the ImageProperties.RetrievePropertiesAsync method. Please see Image Metadata for more information.

The following is a simple code sample:

FileOpenPicker fileOpenPicker = new FileOpenPicker();
fileOpenPicker.FileTypeFilter.Add(".jpg");
fileOpenPicker.FileTypeFilter.Add(".png");
fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;

StorageFile imageFile = await fileOpenPicker.PickSingleFileAsync();
if (imageFile != null)
{
    ImageProperties props = await imageFile.Properties.GetImagePropertiesAsync();
    var requests = new System.Collections.Generic.List<string>();
    requests.Add("System.Photo.EXIFVersion");
    IDictionary<string, object> retrievedProps = await props.RetrievePropertiesAsync(requests);
    if (retrievedProps.ContainsKey("System.Photo.EXIFVersion"))
    {
        var exifVersion = (string)retrievedProps["System.Photo.EXIFVersion"];
    }
}

Please note:

For a complete list of Windows Properties, including the identifiers and type for each property, see Windows Properties.

Some properties are only supported for certain file containers and image codecs. For a listing of the image metadata supported for each image type, see Photo Metadata Policies.

Because properties that are unsupported may return a null value when retrieved, always check for null before using a returned metadata value.