Creating / Writing EXIF ​​Data Using Magick.NET

Using a library based on ImageMagick Magick.NET in C # to add EXIF ​​metadata to processed JPEG, which currently does not have an EXIF ​​profile. Attempts to create a profile failed:

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

ExifProfilehas other constructors that accept a stream or a byte array, and not providing one throws an exception whenever it is called .SetValue():

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)

How to use Magick.NET to write EXIF ​​data?

+4
source share
1 answer

Magick.NET, (https://magick.codeplex.com/workitem/1272). Magick.NET(6.8.9.601) :

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

  image.AddProfile(profile);

  image.Write("logo.withexif.jpg");
}
+5

All Articles