Csharp/C#教程:使用Magick.NET创建/写入EXIF数据分享


使用Magick.NET创建/写入EXIF数据

在C#中使用基于ImageMagick的库Magick.NET将EXIF元数据添加到当前没有EXIF配置文件的已处理JPEG中。 尝试创建配置文件都失败了:

var newExifProfile = image.GetExifProfile(); if (newExifProfile == null) { newExifProfile = new ExifProfile(); } newExifProfile.SetValue(ExifTag.Copyright, "test"); 

ExifProfile有其他构造函数接受一个流或字节数组,不提供一个在.SetValue()时创建一个exception:

 Object reference not set to an instance of an object. at ImageMagick.ExifReader.GetBytes(UInt32 length) at ImageMagick.ExifReader.Read(Byte[] data) at ImageMagick.ExifProfile.SetValue(ExifTag tag, Object value) 

如何使用Magick.NET编写EXIF数据?

您在Magick.NET中发现了一个错误,并且已经修复( https://magick.codeplex.com/workitem/1272 )。 随着Magick.NET的下一个版本(6.8.9.601),你将能够做到这一点:

上述就是C#学习教程:使用Magick.NET创建/写入EXIF数据分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

 using (MagickImage image = new MagickImage("logo:")) { profile = new ExifProfile(); profile.SetValue(ExifTag.Copyright, "Dirk Lemstra"); image.AddProfile(profile); image.Write("logo.withexif.jpg"); } 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/987942.html

(0)
上一篇 2021年12月23日
下一篇 2021年12月23日

精彩推荐