我有50,000+图像的元数据,格式包括.jpeg、.tif、.psd、.pdf等。我试图使用GraphicsMagick.NET将图像的元数据嵌入到它的IPTC字段中。在向图像中添加IPTC配置文件并保存图像之后,它似乎正在工作-- GraphicsMagick可以检索我刚刚为图像保存的IPTC配置文件。
但是,当我查看图像的属性时,我无法看到任何更改。
我做得不对吗?GraphicsMagick不写入标准IPTC字段吗?
下面是一个简单的控制台应用程序来演示我的问题:
class Program
{
static void Main(string[] args)
{
EmbedIptcMetaData();
}
private static void EmbedIptcMetaData()
{
// Picture of a cake found here: https://static.pexels.com/photos/353347/pexels-photo-353347.jpeg
// Labeled for reuse with modification
// Saved to desktop
string desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
string originalFilePath = System.IO.Path.Combine(desktopPath, "pexels-photo-353347.jpeg");
string modifiedFilePath = System.IO.Path.Combine(desktopPath, "pexels-photo-353347-modified.jpeg");
// NuGet package: GraphicsMagick.NET-Q8-AnyCPU
using (GraphicsMagick.MagickImage image = new GraphicsMagick.MagickImage(originalFilePath))
{
// Read the initial IPTC profile of the image
GraphicsMagick.IptcProfile initialProfile = image.GetIptcProfile(); // initialProfile has the image author, Ana Paula Silva
// Create a new IPTC profile
GraphicsMagick.IptcProfile newProfile = new GraphicsMagick.IptcProfile();
newProfile.SetValue(GraphicsMagick.IptcTag.Keyword, "cake,wedding,photography");
// Add the new IPTC profile
image.AddProfile(newProfile);
// Save the image
image.Write(modifiedFilePath); // I expect the IPTC profile to now only have a value for the caption field
}
using (GraphicsMagick.MagickImage modifiedImage = new GraphicsMagick.MagickImage(modifiedFilePath))
{
// Read the modified image's IPTC profile
GraphicsMagick.IptcProfile profile = modifiedImage.GetIptcProfile(); // profile == newProfile from above
}
}
}

发布于 2017-11-08 20:05:57
经过大量的额外研究,看起来GraphicsMagick实际上是在写入图像上的XMP字段。文档是稀疏的,我无法找到将关键字写入除0之外的任何索引的方法。
最后,我转而使用Atalasoft DotImage。
https://stackoverflow.com/questions/47141929
复制相似问题