目前,我正在使用以下代码捕获照片并获取元数据:
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 :(得分:0)
您可以使用ExifLib执行此操作。它支持从内存流中读取标记,如下所示。 它适用于我的Win8.1 StoreApp项目。 UWP也可以。或许。
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());
}
....