How to retrieve and update full file property?

SmilingMoon 981 Reputation points
2020-12-30T19:04:55.923+00:00

52351-image.png

Developing uwp app to update property of photo files,
I cannot find a way to update the properties marked red rectangle such as "ISO Speed". I can do it via Windows Explorer. How can I do it in uwp?

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Yan Gu - MSFT 2,676 Reputation points
    2020-12-31T08:34:30.357+00:00

    Hello,

    Welcome to Microsoft Q&A Case.

    For retrieving the properties of photo file, you can check the following steps.

    1.Create a list of strings and add the identifier for each property you want to retrieve.
    2.Call ImageProperties.RetrievePropertiesAsync method, which takes this list of strings and returns a dictionary of key/value pairs.
    Reference: Image MetaData

    public async void Access()  
            {  
                var folder = KnownFolders.PicturesLibrary;  
                StorageFile imageFile = await folder.GetFileAsync("test1.jpg");  
                if (imageFile!=null)  
                {  
                    ImageProperties props = await imageFile.Properties.GetImagePropertiesAsync();            
                    var requests = new System.Collections.Generic.List<string>();  
                    requests.Add("System.Photo.ISOSpeed");  
    IDictionary<string, object> retrievedProps = await props.RetrievePropertiesAsync(requests);  
    
    if (retrievedProps.ContainsKey("System.Photo.ISOSpeed"))  
                    {  
                        var exifVersion = retrievedProps["System.Photo.ISOSpeed"];  
    }  
    }  
    

    For update the properties of photo file, you can use SavePropertiesAsync() method.

    ImageProperties props = await imageFile.Properties.GetImagePropertiesAsync();  
    var keyvalue = new KeyValuePair<string, object>("System.Photo.ISOSpeed", 100);  
    var properties = new List<KeyValuePair<string, object>>() { keyvalue };  
    await props.SavePropertiesAsync(properties);  
    

    The sample only shows the retrieval and update of “ISOSpeed” property. If you want to know more properties, please refer to the following document. System.Photo


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.