所以我有这个方法来设置一些基本的MetaData标签,最终将添加到我的图像中:
BitmapMetadata metaData = new BitmapMetadata("jpg");
foreach (var t in tags)
{
try
{
switch (t.Key)
{
case "Author":
metaData.Author = new System.Collections.ObjectModel.ReadOnlyCollection<string>(new string[] { t.Value });
break;
case "Rating":
int rating = 0;
if (int.TryParse(t.Value, out rating))
{
metaData.Rating = rating;
}
break;
case "Subject":
metaData.Subject = t.Value;
break;
case "Title":
metaData.Title = t.Value;
break;
case "Comment":
metaData.Comment = t.Value;
break;
default:
keywords.Add(string.Format("{0}:{1}", t.Key, t.Value));
break;
}
}
catch (Exception ex)
{
//Do some logging
}
}
我一直收到错误:
System.NotSupportedException:没有适合的成像组件 完成此操作被发现。 ---&GT; System.Runtime.InteropServices.COMException:来自HRESULT的异常: 0x88982F50 \ ---内部异常堆栈跟踪结束--- \ at System.Windows.Media.Imaging.BitmapMetadata.SetQuery(String query, 对象值)\ at System.Windows.Media.Imaging.BitmapMetadata.set_Title(String value)
在Windows 8.1上作为localhost运行,这很好用。一旦我将我的服务部署到我的Windows Server 2003 Web Edition,它就会抛出显示的错误。发生了什么事?
答案 0 :(得分:2)
对此的修复是明确使用SetQuery作为元数据...... 例如:
BitmapMetadata jpgData = new BitmapMetadata("jpg");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/object name", "Test Title");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/keywords", "Test Tag");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/date created", "20090512");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/time created", "115300-0800");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/caption", "Test Comment");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/by-line", "Test Author");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/copyright notice", "Copyright 2009");
来自对this link的评论
这是因为Windows Server 2003中使用的WIC与Windows 7/8不同,无法更新。所以metadata.Title等throw notfoundexception