首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用GraphicsMagick.NET编辑IPTC字段

使用GraphicsMagick.NET编辑IPTC字段
EN

Stack Overflow用户
提问于 2017-11-06 16:51:48
回答 1查看 379关注 0票数 0

我有50,000+图像的元数据,格式包括.jpeg、.tif、.psd、.pdf等。我试图使用GraphicsMagick.NET将图像的元数据嵌入到它的IPTC字段中。在向图像中添加IPTC配置文件并保存图像之后,它似乎正在工作-- GraphicsMagick可以检索我刚刚为图像保存的IPTC配置文件。

但是,当我查看图像的属性时,我无法看到任何更改。

我做得不对吗?GraphicsMagick不写入标准IPTC字段吗?

下面是一个简单的控制台应用程序来演示我的问题:

代码语言:javascript
复制
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
        }
    }
}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-08 20:05:57

经过大量的额外研究,看起来GraphicsMagick实际上是在写入图像上的XMP字段。文档是稀疏的,我无法找到将关键字写入除0之外的任何索引的方法。

最后,我转而使用Atalasoft DotImage。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47141929

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档