第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

有沒有辦法從所有類型的文件中提取所有元數(shù)據(jù)?

有沒有辦法從所有類型的文件中提取所有元數(shù)據(jù)?

C#
慕桂英3389331 2023-09-16 17:53:15
我正在嘗試從一堆文件中提取元數(shù)據(jù)。這些文件可以是圖像、視頻或任何類型。我想從文件中提取所有可用的元數(shù)據(jù),無論類型如何。我嘗試使用WindowsAPICodePack和Shell32。我能夠提取一堆屬性,但我需要文件中提供的“投影類型”元數(shù)據(jù)。但兩者WindowsAPICodePack都Shell32未能提取相同的內(nèi)容。有什么解決辦法嗎?這是Shell 32我嘗試過的代碼List<string> arrHeaders = new List<string>();List<Tuple<int, string, string>> attributes = new List<Tuple<int, string, string>>();Shell32.Shell shell = new Shell32.Shell();var strFileName = @"C:\Users\Admin\Google Drive\image.jpg";Shell32.Folder objFolder = shell.NameSpace(System.IO.Path.GetDirectoryName(strFileName));Shell32.FolderItem folderItem = objFolder.ParseName(System.IO.Path.GetFileName(strFileName));for (int i = 0; i < short.MaxValue; i++){    string header = objFolder.GetDetailsOf(null, i);    if (String.IsNullOrEmpty(header))        break;    arrHeaders.Add(header);}// The attributes list below will contain a tuple with attribute index, name and value// Once you know the index of the attribute you want to get, // you can get it directly without looping, like this:var Authors = objFolder.GetDetailsOf(folderItem, 20);for (int i = 0; i < arrHeaders.Count; i++){    var attrName = arrHeaders[i];    var attrValue = objFolder.GetDetailsOf(folderItem, i);    var attrIdx = i;    attributes.Add(new Tuple<int, string, string>(attrIdx, attrName, attrValue));    Debug.WriteLine("{0}\t{1}: {2}", i, attrName, attrValue);}Console.ReadLine();WindowsAPICodePack下面給出了代碼。ShellObject file = ShellObject.FromParsingName(path);            var props = file.Properties.DefaultPropertyCollection;            var camera = file.Properties.GetProperty(SystemProperties.System.Photo.CameraModel);
查看完整描述

1 回答

?
aluckdog

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超7個(gè)贊

好吧,經(jīng)過一番搜索后,我最終使用了Phil Harvey 的 ExifTool。

該工具在提取大量元數(shù)據(jù)方面非常有效,尤其是我特別需要的“ProjectionType”。該屬性用于檢查上傳的文件是否為 360 度視頻/圖像。這幾乎就是我最終得到的結(jié)果。

public List<Metadata> ExtractMetaDataExifTool(string filepath, string ExifToolPath)

? ? {

? ? ? ? #region ReadFromFile

? ? ? ? string output = "";

? ? ? ? var lstMetadata = new List<Metadata>();

? ? ? ? using (var p = new Process())

? ? ? ? {

? ? ? ? ? ? // exiftool command

? ? ? ? ? ? string toolPath = "";

? ? ? ? ? ? toolPath += " -s ";

? ? ? ? ? ? toolPath += "-fast -G -t -m -q -q -n ";

? ? ? ? ? ? toolPath += "\"" + filepath + "\"";


? ? ? ? ? ? System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();

? ? ? ? ? ? startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

? ? ? ? ? ? startInfo.FileName = "\"" + ExifToolPath + "\\exiftool.exe" + "\"";

? ? ? ? ? ? startInfo.Arguments = toolPath;

? ? ? ? ? ? startInfo.RedirectStandardOutput = true;

? ? ? ? ? ? startInfo.UseShellExecute = false;

? ? ? ? ? ? p.StartInfo = startInfo;

? ? ? ? ? ? bool status = p.Start();


? ? ? ? ? ? StringBuilder q = new StringBuilder();

? ? ? ? ? ? while (!p.HasExited)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? q.Append(p.StandardOutput.ReadToEnd());

? ? ? ? ? ? }

? ? ? ? ? ? output = q.ToString();

? ? ? ? ? ? p.WaitForExit();

? ? ? ? }

? ? ? ? #endregion ReadFromFile


? ? ? ? #region ExtractFileMetadataFromString


? ? ? ? while (output.Length > 0)

? ? ? ? {

? ? ? ? ? ? int epos = output.IndexOf('\r');


? ? ? ? ? ? if (epos < 0)

? ? ? ? ? ? ? ? epos = output.Length;

? ? ? ? ? ? string tmp = output.Substring(0, epos);

? ? ? ? ? ? int tpos1 = tmp.IndexOf('\t');

? ? ? ? ? ? int tpos2 = tmp.IndexOf('\t', tpos1 + 1);


? ? ? ? ? ? if (tpos1 > 0 && tpos2 > 0)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? string taggroup = tmp.Substring(0, tpos1);

? ? ? ? ? ? ? ? ++tpos1;

? ? ? ? ? ? ? ? string tagname = tmp.Substring(tpos1, tpos2 - tpos1);

? ? ? ? ? ? ? ? ++tpos2;

? ? ? ? ? ? ? ? string tagvalue = tmp.Substring(tpos2, tmp.Length - tpos2);


? ? ? ? ? ? ? ? // special processing for tags with binary data?

? ? ? ? ? ? ? ? tpos1 = tagvalue.IndexOf(", use -b option to extract");

? ? ? ? ? ? ? ? if (tpos1 >= 0)

? ? ? ? ? ? ? ? ? ? tagvalue.Remove(tpos1, 26);


? ? ? ? ? ? ? ? if (!string.IsNullOrEmpty(taggroup) && !string.IsNullOrEmpty(tagname) && !string.IsNullOrEmpty(tagvalue))

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? lstMetadata.Add(new Metadata

? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? group = taggroup?.Trim(),

? ? ? ? ? ? ? ? ? ? ? ? name = tagname?.Trim(),

? ? ? ? ? ? ? ? ? ? ? ? value = tagvalue?.Trim()

? ? ? ? ? ? ? ? ? ? });

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }


? ? ? ? ? ? // is \r followed by \n ?

? ? ? ? ? ? if (epos < output.Length)

? ? ? ? ? ? ? ? epos += (output[epos + 1] == '\n') ? 2 : 1;

? ? ? ? ? ? output = output.Substring(epos, output.Length - epos);

? ? ? ? }

? ? ? ? #endregion ExtractFileMetadataFromString


? ? ? ? return lstMetadata;

? ? }


查看完整回答
反對(duì) 回復(fù) 2023-09-16
  • 1 回答
  • 0 關(guān)注
  • 124 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)