2017-10-05 93 views
1

目前,我拍攝的照片,並使用下面的代碼得到一個元數據:檢索EXIF數據從UWP拍攝不保存到磁盤

using (var imageStream = new InMemoryRandomAccessStream()) 
{ 
    await _capture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), imageStream); 
    var folder = await StorageFolder.GetFolderFromPathAsync(MediaBuilderSettings.GetScratchDirectory()); 
    var storageFile = await folder.CreateFileAsync(System.Guid.NewGuid().ToString() + ".jpg", CreationCollisionOption.ReplaceExisting); 
    var storageFileStream = await storageFile.OpenAsync(FileAccessMode.ReadWrite); 
    await RandomAccessStream.CopyAndCloseAsync(imageStream, storageFileStream); 
    List<string> imageMetaRetrieveList = new List<string> { "System.Photo.Aperture", "System.Photo.Brightness" }; 
    IDictionary<string, object> extraProperties = await storageFile.Properties.RetrievePropertiesAsync(imageMetaRetrieveList); 
} 

是否有訪問EXIF數據不保存方式圖像到磁盤?

回答

0

你可以用ExifLib來做到這一點。它支持從內存流中讀取標籤,如下所示。 它適用於我的Win8.1 StoreApp項目。 UWP也可以。

ExifLib - nuget

using ExifLib; 
... 
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(buffer)) 
{ 
    using (var reader = new ExifReader(stream)) 
    { 
     object value = null; 
     string exifstr = ""; 
     // ISO 
     reader.GetTagValue<object>(ExifTags.ISOSpeedRatings, out value); 
     if (null != value && typeof(UInt16) == value.GetType()) 
     { 
      exifstr += ("ISO" + value.ToString()); 
     } 
     .... 
+0

希望爲沒有第三方的lib的解決方案,但是這看起來像它會做的伎倆。謝謝。 – Mike