Skip to content

Latest commit

 

History

History
79 lines (55 loc) · 3.75 KB

bitmappropertiesview_getpropertiesasync_1829853186.md

File metadata and controls

79 lines (55 loc) · 3.75 KB
-api-id -api-type
M:Windows.Graphics.Imaging.BitmapPropertiesView.GetPropertiesAsync(Windows.Foundation.Collections.IIterable{System.String})
winrt method

Windows.Graphics.Imaging.BitmapPropertiesView.GetPropertiesAsync

-description

Asynchronously retrieves one or more bitmap properties.

-parameters

-param propertiesToRetrieve

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

Object that manages the asynchronous retrieval of the bitmap properties.

-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.

-examples

-see-also

BitmapPropertySet, BitmapTypedValue