public SetValue ( ExifTag tag, object value ) : void | ||
tag | ExifTag | The tag of the exif value. |
value | object | The value. |
return | void |
public bool Save(string rootpath) { bool success = false; ImageMagick.ExifProfile exifprofile = new ImageMagick.ExifProfile(); exifprofile.SetValue(ExifTag.Copyright, " ©" + Copyright); exifprofile.SetValue(ExifTag.Artist, Creator); exifprofile.SetValue(ExifTag.ImageDescription, Subject); exifprofile.SetValue(ExifTag.Software, Software); _image.AddProfile(exifprofile); ImageMagick.IptcProfile iptcprofile = new ImageMagick.IptcProfile(); iptcprofile.SetValue(IptcTag.CopyrightNotice, "No Unauthorized reproduction ©" + Copyright); iptcprofile.SetValue(IptcTag.Byline, Creator); iptcprofile.SetValue(IptcTag.Country, Country); iptcprofile.SetValue(IptcTag.Headline, Headline); iptcprofile.SetValue(IptcTag.Keyword, Keywords); iptcprofile.SetValue(IptcTag.Source, Source); iptcprofile.SetValue(IptcTag.Caption, Subject); iptcprofile.SetValue(IptcTag.Title, Title); _image.AddProfile(iptcprofile); _image.Write(rootpath); success = true; return(success); }
public void Test_InvalidTag() { var exifProfile = new ExifProfile(); ExceptionAssert.Throws<NotSupportedException>(() => { exifProfile.SetValue((ExifTag)42, 42); }); }
public void Test_ExifTag() { var exifProfile = new ExifProfile(); exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)1); ExifValue value = exifProfile.GetValue(ExifTag.ResolutionUnit); Assert.AreEqual("None", value.ToString()); exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)2); value = exifProfile.GetValue(ExifTag.ResolutionUnit); Assert.AreEqual("Inches", value.ToString()); exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)3); value = exifProfile.GetValue(ExifTag.ResolutionUnit); Assert.AreEqual("Centimeter", value.ToString()); exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)4); value = exifProfile.GetValue(ExifTag.ResolutionUnit); Assert.AreEqual("4", value.ToString()); exifProfile.SetValue(ExifTag.ImageWidth, 123); value = exifProfile.GetValue(ExifTag.ImageWidth); Assert.AreEqual("123", value.ToString()); }
public void Test_UnknownExifTag() { var exifProfile = new ExifProfile(); exifProfile.SetValue(ExifTag.ImageWidth, 42); var bytes = exifProfile.ToByteArray(); bytes[16] = 42; exifProfile = new ExifProfile(bytes); ExifTag unkownTag = (ExifTag)298; ExifValue value = exifProfile.GetValue(unkownTag); Assert.AreEqual(42, value.Value); Assert.AreEqual("42", value.ToString()); bytes = exifProfile.ToByteArray(); Assert.AreEqual(0, bytes.Length); }
public void Test_Constructor() { using (MemoryStream memStream = new MemoryStream()) { using (MagickImage image = new MagickImage(Files.ImageMagickJPG)) { ExifProfile profile = image.GetExifProfile(); Assert.IsNull(profile); profile = new ExifProfile(); profile.SetValue(ExifTag.Copyright, "Dirk Lemstra"); image.AddProfile(profile); profile = image.GetExifProfile(); Assert.IsNotNull(profile); image.Write(memStream); } memStream.Position = 0; using (MagickImage image = new MagickImage(memStream)) { ExifProfile profile = image.GetExifProfile(); Assert.IsNotNull(profile); Assert.AreEqual(1, profile.Values.Count()); ExifValue value = profile.Values.FirstOrDefault(val => val.Tag == ExifTag.Copyright); TestValue(value, "Dirk Lemstra"); } } }