如何从base64数据网址获取exif数据?

时间:2018-04-23 05:39:34

标签: c# xamarin xamarin.forms exif

我目前正在下载已作为基本64字符串存储在我的数据库中的图像。问题是我还需要获取图像EXIF数据以确定图像方向。我想知道他们是否是获取EXIF数据的方法。

以下是我的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);
 }

上面的代码加载了填充列表项所需的数据,正如您所看到的,我能够使用此代码tool.photos获取图像的数据URL。但我似乎无法弄清楚如何获取EXIF数据。他们的插件或一些c#代码可以从base64字符串甚至是字节数组中获取吗?

感谢。

1 个答案:

答案 0 :(得分:2)

您可以使用Convert.FromBase64String获取func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return dictionary1.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell:TableViewCell = tableView.dequeueReusableCell(withIdentifier: "cell") as! TableViewCell // FOR FIRST DICTIONARY cell.questionLabel?.numberOfLines = 0 cell.questionLabel?.lineBreakMode = .byWordWrapping cell.questionLabel?.text = dictionary1[indexPath.row] // FOR SECOND DICTIONARY cell.optionsLabel?.numberOfLines = 0 cell.optionsLabel?.lineBreakMode = .byWordWrapping cell.optionsLabel?.text = dictionary2[indexPath.row]?.joined(separator: "\n") return cell } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return UITableViewAutomaticDimension } func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { return 350.0 } 图片数据。

有了这个,您可以使用MetadataExtractor来访问图片中的所有元数据,而不仅仅是Exif:

byte[]

图书馆可通过NuGet获取:https://www.nuget.org/packages/MetadataExtractor/

(自2002年以来,我一直在维护这个项目。)