简体   繁体   English

如何从base64数据URL获取exif数据?

[英]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.

相关问题 如何将具有 base64 的数据类型长文本转换为从数据库到特定列上的 gridview 的图像? - How to convert data type longtext with base64 to image from data base to gridview on specific column? URL编码的Base64编码的文件数据 - URL Encoded Base64 Encoded File Data 如何将文本字符串从Base64解码为字节数组,以及如何在不破坏数据的情况下获取此字节数组的string属性 - How to decode a string of text from a Base64 to a byte array, and the get the string property of this byte array without data corruption 如何将从数据读取器读取的数据转换为base64字符串并添加到datatable? - How to convert data read from data reader to base64 string and add to datatable? 从POST返回的Rowversion数据无效base64 - Returned Rowversion data from a POST is not valid base64 .net字符串中如何存储base64编码的数据? - How is base64 encoded data stored in .Net strings? 如何在URL中发送base64字符串? - How to send base64 string in a url? 如何从AjaxFileUpload获取base64图像? - How to get base64 image from AjaxFileUpload? 如何从Javascript中的Base64字符串获取ZIP文件? - How to get the ZIP file from Base64 string in Javascript? 发布base64转换的图像数据 - Posting base64 converted image data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM