Reputation: 528
I need to get Jpeg properties from a image taken from the image library in the phone. In another XAML project I could use
var myImage = System.Drawing.Image.FromStream(myImageStream);
foreach(var imageProperty in myImage.PropertyItems)
//do things
How should I do in Windows Phone 8.1? I need property with Id 274 (Orientation) to be able to rotate the image to correct orientation
Upvotes: 0
Views: 727
Reputation: 721
First be sure to allow access to the Pictures Library in your application manifest.
Then this code should work:
// First get the list of all your pictures in the pictures library
var allMyPictures = await KnownFolders.PicturesLibrary.GetFilesAsync();
// iterate trough your pictures
foreach (var file in allMyPictures)
{
// Get all the properties
var properties = await file.Properties.GetImagePropertiesAsync();
// Get the orientation
var orientation = properties.Orientation;
}
Be aware that pictures taken from the phone camera are not directly saved in the pictures library but in a subfolder ("Camera Roll" on my Nokia). If it's the case on yours you need to adapt like that:
// Get the Camera Roll subfolder
var cameraRollFolder = await KnownFolders.PicturesLibrary.GetFolderAsync("Camera Roll");
// Get all the pictures from this specific directory
var allMyPicturesFromCameraRoll = await cameraRollFolder.GetFilesAsync();
This code was tested on my Nokia 635 but should work on any Windows Phone 8
Upvotes: 3