我目前正在使用以下代码通过exiftool将标签添加到图像。 效果很好。但是当图像中已经有标签时,它们不会被替换。
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "exiftool.exe";
startInfo.Arguments = "-m -stay_open True -@ " + tempDirectory + "\\commands.txt";
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
Process processTemp = new Process();
processTemp.StartInfo = startInfo;
processTemp.EnableRaisingEvents = true;
processTemp.Start();
return true;
将命令写入由exiftool监视的文本文件
writer = new FileInfo(tempDirectory + "commands.txt").AppendText();
writer.WriteLine("-subject=" + tempstring);
writer.WriteLine(outdir + "\\" + x.Value.ElementAt(0) + "\\" + Path.GetFileName(x.Key));
writer.WriteLine("-overwrite_original");
if (counter != files.Count)
{
writer.WriteLine("-execute");
}
else
{
writer.WriteLine("-stay_open");
writer.WriteLine("False");
}