ImageProperties ImageProperties ImageProperties ImageProperties Class

Provides access to the image-related properties of an item (like a file or folder).

Syntax

Declaration

public sealed class ImagePropertiespublic sealed class ImagePropertiesPublic NotInheritable Class ImagePropertiespublic sealed class ImageProperties

Remarks

You can access a ImageProperties object asynchronously using the GetImagePropertiesAsync() method from the Properties property of an item (like a file of folder), or synchronously using the ImageProperties property if it is available. You can get a ImageProperties object using any of the following methods and properties:

Note

Properties that are get or set using a property handler that is defined by another app (like Microsoft Word) may not be accessible. Instead, you can try to get these properties using a file query that is backed by the system index. For more information, see QueryOptions.

For more code samples about accessing properties, see the File access sample.

Examples

This example demonstrates how to retrieve properties of a file, including image properties like DateTaken and Rating.


try
{
    StorageFile file = rootPage.sampleFile;
    if (file != null)
    {
        StringBuilder outputText = new StringBuilder();

        // Get image properties
        ImageProperties imageProperties = await file.Properties.GetImagePropertiesAsync();
        outputText.AppendLine("Date taken: " + imageProperties.DateTaken);
        outputText.AppendLine("Rating: " + imageProperties.Rating);
    }
}
// Handle errors with catch blocks
catch (FileNotFoundException)
{
 // For example, handle a file not found error
}

var file = SdkSample.sampleFile;
if (file !== null) {
    var outputDiv = document.getElementById("output");

    // Get image properties
    file.properties.getImagePropertiesAsync().done(function (imageProperties) {
        outputDiv.innerHTML += "Date taken: " + imageProperties.dateTaken + "<br/>";
        outputDiv.innerHTML += "Rating: " + imageProperties.rating + "<br/>";
    },
    // Handle errors with an error function
    function (error) {
       // Handle errors encountered while retrieving properties
    });
}

After GetImagePropertiesAsync() completes, imageProperties gets a ImageProperties object.

In the example, file contains a StorageFile that represents the file to retrieve properties for.

Properties summary

Gets or sets the manufacturer of the camera that took the photo.

Gets or sets the model of the camera that took the photo.

Gets or sets the date when the image was taken.

Gets the height of the image.

Gets the collection of keywords associated with the image.

Gets the latitude coordinate where the photo was taken.

Gets the longitude coordinate where the photo was taken.

Gets the Exchangeable Image File (EXIF) orientation flag of the photo.

Gets the names of people who are tagged in the photo.

Gets or sets the rating associated with an image file.

Gets or sets the title of the image.

Gets the width of the image.

Methods summary

Retrieves the specified properties associated with the item.

Saves all properties associated with the item.

Saves the specified properties and values associated with the item.

Properties

  • CameraManufacturer
    CameraManufacturer
    CameraManufacturer
    CameraManufacturer

    Gets or sets the manufacturer of the camera that took the photo.

    public string CameraManufacturer { get; set; }public string CameraManufacturer { get; set; }Public ReadWrite Property CameraManufacturer As stringpublic string CameraManufacturer { get; set; }

    Property Value

    • string
      string
      string
      string

      The manufacturer of the camera that took the photo.

  • CameraModel
    CameraModel
    CameraModel
    CameraModel

    Gets or sets the model of the camera that took the photo.

    public string CameraModel { get; set; }public string CameraModel { get; set; }Public ReadWrite Property CameraModel As stringpublic string CameraModel { get; set; }

    Property Value

    • string
      string
      string
      string

      The model of the camera that took the photo.

  • DateTaken
    DateTaken
    DateTaken
    DateTaken

    Gets or sets the date when the image was taken.

    public DateTime DateTaken { get; set; }public DateTimeOffset DateTaken { get; set; }Public ReadWrite Property DateTaken As DateTimeOffsetpublic DateTime DateTaken { get; set; }

    Property Value

    Remarks

    If the date property isn't set, this value defaults to 0 which can be translated into misleading dates in different programming languages. In JavaScript, for example, 0 translates to December 16, 1600. You should always check that this property is a real value and not 0.

  • Height
    Height
    Height
    Height

    Gets the height of the image.

    public uint Height { get; }public uint Height { get; }Public ReadOnly Property Height As uintpublic uint Height { get; }

    Property Value

    • uint
      uint
      uint
      uint

      The height of the image

      , in pixels.

  • Keywords
    Keywords
    Keywords
    Keywords

    Gets the collection of keywords associated with the image.

    public IVector<string> Keywords { get; }public IVector<string> Keywords { get; }Public ReadOnly Property Keywords As IVector<string>public IVector<string> Keywords { get; }

    Property Value

    • The collection of keywords.

    Remarks

    This property is read-only. It returns a collection, and you can't delete or replace the collection itself. The contents of the collection, however, are not read-only. You can add items to the collection, remove items from the collection, and change existing items in the collection. Call the SavePropertiesAsync method of the parent class to save the updated contents of the collection.

  • Latitude
    Latitude
    Latitude
    Latitude

    Gets the latitude coordinate where the photo was taken.

    public IReference<double> Latitude { get; }public IReference<double> Latitude { get; }Public ReadOnly Property Latitude As IReference<double>public IReference<double> Latitude { get; }

    Property Value

    Remarks

    To set the latitude or longitude of the photo, you must set all four of the file properties that are used to compute the latitude coordinate.

    For code examples that demonstrate working with Latitude, Longitude and their underlying file properties, see the Simple imaging sample.

  • Longitude
    Longitude
    Longitude
    Longitude

    Gets the longitude coordinate where the photo was taken.

    public IReference<double> Longitude { get; }public IReference<double> Longitude { get; }Public ReadOnly Property Longitude As IReference<double>public IReference<double> Longitude { get; }

    Property Value

  • Orientation
    Orientation
    Orientation
    Orientation

    Gets the Exchangeable Image File (EXIF) orientation flag of the photo.

    public PhotoOrientation Orientation { get; }public PhotoOrientation Orientation { get; }Public ReadOnly Property Orientation As PhotoOrientationpublic PhotoOrientation Orientation { get; }

    Property Value

  • PeopleNames
    PeopleNames
    PeopleNames
    PeopleNames

    Gets the names of people who are tagged in the photo.

    public IVectorView<string> PeopleNames { get; }public IVectorView<string> PeopleNames { get; }Public ReadOnly Property PeopleNames As IVectorView<string>public IVectorView<string> PeopleNames { get; }

    Property Value

    • A list of the names of people who are tagged in the photo.

    Remarks

    This property is read-only, similar to the Keywords property.

  • Rating
    Rating
    Rating
    Rating

    Gets or sets the rating associated with an image file.

    public uint Rating { get; set; }public uint Rating { get; set; }Public ReadWrite Property Rating As uintpublic uint Rating { get; set; }

    Property Value

    • uint
      uint
      uint
      uint

      The media file rating, as a value between 0 and 99.

    Remarks

    The rating property for this media file type is obtained from the Windows file properties, specifically from System.Rating. System.Rating has a value from 0 to 99. A value of 0 indicates that the file has not been rated.

    Rating info is often presented to the user as a “star” metaphor, where a star rating can be from 0 to 5 stars. This is shown as the outline of 5 star shapes, with the current rating indicated by a horizontal color bar within the 5 star shapes. For more info, see Guidelines for the Rating control.

    For HTML UI, the Rating control implements a star-rating behavior, but you’ll have convert a Rating property value into the star-count values that the Rating control uses for its properties.

    For XAML UI there is no default rating control in the Windows Runtime XAML vocabulary. However, several third-party control vendors have created a XAML rating control.

    Here’s some suggested logic for converting the 0-99 possible value of a Rating property to an integer value between 0 and 5 that is suitable for a 5-star UI presentation metaphor, and for the Rating control: uint starRating = rating == 0 ? 0 : (uint)Math.Round((double)rating / 25.0) + 1;.

  • Title
    Title
    Title
    Title

    Gets or sets the title of the image.

    public string Title { get; set; }public string Title { get; set; }Public ReadWrite Property Title As stringpublic string Title { get; set; }

    Property Value

    • string
      string
      string
      string

      The image title.

  • Width
    Width
    Width
    Width

    Gets the width of the image.

    public uint Width { get; }public uint Width { get; }Public ReadOnly Property Width As uintpublic uint Width { get; }

    Property Value

    • uint
      uint
      uint
      uint

      The width of the image

      , in pixels.

Methods

  • RetrievePropertiesAsync(IIterable<String>)
    RetrievePropertiesAsync(IIterable<String>)
    RetrievePropertiesAsync(IIterable<String>)
    RetrievePropertiesAsync(IIterable<String>)

    Retrieves the specified properties associated with the item.

    public IAsyncOperation<IMap<string, object>> RetrievePropertiesAsync(IIterable<String> propertiesToRetrieve)public IAsyncOperation<IMap<string, object>> RetrievePropertiesAsync(IIterable<String> propertiesToRetrieve)Public Function RetrievePropertiesAsync(propertiesToRetrieve As IIterable<String>) As IAsyncOperation( Of IMapstring, object )public IAsyncOperation<IMap<string, object>> RetrievePropertiesAsync(IIterable<String> propertiesToRetrieve)

    Parameters

    • propertiesToRetrieve

      A collection that contains the names of the properties to retrieve.

    Returns

    • When this method completes successfully, it returns a collection (type IMap<K, V> ) that contains the specified properties and values as key-value pairs.

    Remarks

    In JavaScript, use then or done to specify handler functions that will capture and process the collection when it is returned.

  • SavePropertiesAsync()
    SavePropertiesAsync()
    SavePropertiesAsync()
    SavePropertiesAsync()

    Saves all properties associated with the item.

    public IAsyncAction SavePropertiesAsync()public IAsyncAction SavePropertiesAsync()Public Function SavePropertiesAsync() As IAsyncActionpublic IAsyncAction SavePropertiesAsync()

    Returns

    Remarks

    If any one of the property values is invalid, none of the values will be saved.

  • SavePropertiesAsync(IIterable<IKeyValuePair<String, Object>>)
    SavePropertiesAsync(IIterable<IKeyValuePair<String, Object>>)
    SavePropertiesAsync(IIterable<IKeyValuePair<String, Object>>)
    SavePropertiesAsync(IIterable<IKeyValuePair<String, Object>>)

    Saves the specified properties and values associated with the item.

    public IAsyncAction SavePropertiesAsync(IIterable<IKeyValuePair<String, Object>> propertiesToSave)public IAsyncAction SavePropertiesAsync(IIterable<IKeyValuePair<String, Object>> propertiesToSave)Public Function SavePropertiesAsync(propertiesToSave As IIterable<IKeyValuePair<String, Object>>) As IAsyncActionpublic IAsyncAction SavePropertiesAsync(IIterable<IKeyValuePair<String, Object>> propertiesToSave)

    Parameters

    • propertiesToSave

      A collection that contains the names and values of the properties to save as key-value pairs (type IKeyValuePair<K, V> ).

    Returns

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute

Details

Assembly

Windows.Storage.FileProperties.dll