ImageMagick.IptcProfile.SetValue C# (CSharp) Method

SetValue() public method

Sets the value of the specified tag.
public SetValue ( IptcTag tag, Encoding encoding, string value ) : void
tag IptcTag The tag of the iptc value.
encoding System.Text.Encoding The encoding to use when storing the bytes.
value string The value.
return void
    public void SetValue(IptcTag tag, Encoding encoding, string value)
    {
      Throw.IfNull(nameof(encoding), encoding);

      foreach (IptcValue iptcValue in Values)
      {
        if (iptcValue.Tag == tag)
        {
          iptcValue.Encoding = encoding;
          iptcValue.Value = value;
          return;
        }
      }

      _Values.Add(new IptcValue(tag, encoding, value));
    }

Same methods

IptcProfile::SetValue ( IptcTag tag, string value ) : void

Usage Example

Example #1
1
    public void Test_IptcProfile()
    {
      using (MagickImage input = new MagickImage(Files.MagickNETIconPNG))
      {
        IptcProfile profile = input.GetIptcProfile();
        Assert.IsNull(profile);

        profile = new IptcProfile();
        profile.SetValue(IptcTag.Headline, "Magick.NET");
        profile.SetValue(IptcTag.CopyrightNotice, "Copyright.NET");

        input.AddProfile(profile);

        using (MemoryStream memStream = new MemoryStream())
        {
          input.Format = MagickFormat.Tiff;
          input.Write(memStream);

          memStream.Position = 0;
          using (MagickImage output = new MagickImage(memStream))
          {
            profile = output.GetIptcProfile();
            Assert.IsNotNull(profile);
            TestValue(profile, IptcTag.Headline, "Magick.NET");
            TestValue(profile, IptcTag.CopyrightNotice, "Copyright.NET");
          }
        }
      }
    }
All Usage Examples Of ImageMagick.IptcProfile::SetValue