[英]How to get exif data from base64 data url?
I am currently downloading images that have been stored as a base 64 string on my database. 我目前正在下载以base 64字符串存储在数据库中的图像。 The issue is that I need to also get the images EXIF data to determine the images orientation. 问题是我还需要获取图像EXIF数据来确定图像方向。 I am wondering if their is a way to get the EXIF data. 我想知道他们是否是获取EXIF数据的一种方法。
The following is my c# code. 以下是我的C#代码。
busyMessage.Text = "Loading Tools";
InvToolSync toolSync = new InvToolSync();
toolData = await toolSync.GetTools(viewModel.CompanyData.company_id);
foreach (Tool tool in toolData)
{
if (tool.archived == "True")
continue;
var lt = new ListTemplate(tool.id, tool.name, ImageSource.FromFile("default_image.png"));
if (!string.IsNullOrEmpty(tool.photos))
if (tool.photos.Length % 4 == 0)
lt.SourceImage = ImageSource.FromStream(() => new MemoryStream(Convert.FromBase64String(tool.photos)));
listDisplay.Add(lt);
}
The above code loads the the data required to populate a list item and as you can see I am able I get the image's data url with this code tool.photos
. 上面的代码加载了填充列表项所需的数据,如您所见,我能够使用此代码tool.photos
获取图像的数据URL。 But I cannot seem to figure out how to get the EXIF data. 但是我似乎无法弄清楚如何获取EXIF数据。 Is their a plugin or some c# code that could get this from a base64 string or even a the byte array? 是他们的插件还是一些c#代码,它们可以从base64字符串甚至字节数组中获取此信息?
Thanks. 谢谢。
You can use Convert.FromBase64String
to get a byte[]
of your image data. 您可以使用Convert.FromBase64String
来获取图像数据的byte[]
。
With that, you can use MetadataExtractor to access all the metadata from the image, not just Exif: 这样,您可以使用MetadataExtractor来访问图像中的所有元数据,而不仅仅是Exif:
var directories = ImageMetadataReader.ReadMetadata(
new MemoryStream(bytes));
foreach (var directory in directories)
foreach (var tag in directory.Tags)
Console.WriteLine($"{directory.Name} - {tag.Name} = {tag.Description}");
The library is available via NuGet here: https://www.nuget.org/packages/MetadataExtractor/ 该库可通过NuGet此处获得: https : //www.nuget.org/packages/MetadataExtractor/
(I have maintained this project since 2002.) (自2002年以来,我一直在维护这个项目。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.