BitmapPropertiesView BitmapPropertiesView BitmapPropertiesView BitmapPropertiesView Class

Definition

Provides read access to image properties and metadata. A particular instance of BitmapPropertiesView may represent the entire contents of the frame metadata, or any nested metadata block within the frame.

public : sealed class BitmapPropertiesView : IBitmapPropertiesView
public sealed class BitmapPropertiesView : IBitmapPropertiesView
Public NotInheritable Class BitmapPropertiesView Implements IBitmapPropertiesView
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Methods

GetPropertiesAsync(IIterable) GetPropertiesAsync(IIterable) GetPropertiesAsync(IIterable) GetPropertiesAsync(IIterable)

Asynchronously retrieves one or more bitmap properties.

public : IAsyncOperation<BitmapPropertySet> GetPropertiesAsync(IIterable<Platform::String> propertiesToRetrieve)
public IAsyncOperation<BitmapPropertySet> GetPropertiesAsync(IEnumerable<String> propertiesToRetrieve)
Public Function GetPropertiesAsync(propertiesToRetrieve As IEnumerable<String>) As IAsyncOperation( Of BitmapPropertySet )
Windows.Graphics.Imaging.BitmapPropertiesView.getPropertiesAsync(propertiesToRetrieve).done( /* Your success and error handlers */ );
Parameters
propertiesToRetrieve
IIterable<Platform::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

A collection of strings representing the property keys or queries that are being requested. Valid strings include Windows properties and Windows Imaging Component metadata queries.

Returns

Remarks

The asynchronous operation produces a collection representing the requested image property keys and their values. The values are stored as BitmapTypedValue, which contains both the actual data as well as the PropertyType of the data.

A particular image may only contain some (or none) of the requested properties. In this case the collection will only have key-value pairs for the properties which were found in the image. You need to check for the existence of the property before you attempt to get data from it:

bitmapPropertiesView.getPropertiesAsync(["System.Title"]).done(function (retrievedProperties) {
  if (retrievedProperties.hasKey("System.Title")) {
        var titleProperty = retrievedProperties.lookup("System.Title");
        var title = titleProperty.value;
     }
});

Querying for a metadata block

If you use the metadata query language to request a metadata block instead of a property, the returned value is a BitmapPropertiesView representing the metadata within that block. You can request any metadata contained within the block from the BitmapPropertiesView:

// this is equivalent to directly requesting "/app1/ifd/{ushort=274}" from bitmapPropertiesView
bitmapPropertiesView.getPropertiesAsync(["/app1/ifd"]).done(function (retrievedProperties) {
      // var ifdBlock is a BitmapPropertiesView
      var ifdBlock = retrievedProperties.lookup("/app1/ifd").value;
      return ifdBlock.getPropertiesAsync(["/{ushort=274}");
}).then(function (retrievedProperties) {
      var orientation = retrievedProperties.lookup("/{ushort=274}").value;
});

Enumerating through all the metadata within a frame

You can request all of the contents of a metadata block, including sub-blocks and properties, by passing in an empty (zero length) collection of strings. This produces a collection containing every sub-block and property within the BitmapPropertiesView ’s scope. In this way, you are able to iteratively retrieve all of the metadata contained within an image frame.

bitmapPropertiesView.getPropertiesAsync([]).done(function (retrievedProperties) {
      var iterator = retrievedProps.first();
      while (iterator.hasCurrent) {
          // iterator.current gives a key-value pair of string, BitmapTypedValue
          // nextMetadataBlock is a BitmapPropertiesView containing the sub-block
          var nextMetadataBlock = iterator.current.value.value;
          iterator.moveNext();
    }
});

If the image format does not support metadata, it will fail with HRESULT WINCODEC_ERR_UNSUPPORTEDOPERATION.