【问题标题】:Using GraphicsMagick.NET to edit IPTC fields使用 GraphicsMagick.NET 编辑 IPTC 字段
【发布时间】:2017-11-06 16:51:48
【问题描述】:

我有 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
        }
    }
}

【问题讨论】:

    标签: c# .net graphicsmagick iptc


    【解决方案1】:

    经过大量额外研究,GraphicsMagick 似乎实际上是在向图像上的 XMP 字段写入数据。文档很少,我无法找到将关键字写入除 0 以外的任何索引的方法。

    最后我改用 Atalasoft DotImage。

    【讨论】:

      猜你喜欢
      • 2013-07-09
      • 2014-11-17
      • 2020-08-09
      • 2019-01-13
      • 2011-08-15
      • 2013-01-31
      • 1970-01-01
      • 2020-11-27
      • 1970-01-01
      相关资源
      最近更新 更多