Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Annotating Images - Labeling Below (or Above) an Image

$
0
0
You can either use the Annotate method of MagickImage or 'read' the label and append it to your image. Below are two examples of how you could do this:
// Fixed label heightusing (MagickImage image = new MagickImage("logo:"))
{
  image.Extent(image.Width, image.Height + 20, Gravity.North, new MagickColor("Plum"));
  image.Annotate("Magick.NET", Gravity.South);
  image.Write("output-a.png");
}

// Dynamic label heightusing (MagickImageCollection images = new MagickImageCollection())
{
  // Read the image you want to put a label on.
  MagickImage logo = new MagickImage("logo:");
  images.Add(logo);

  MagickImage label = new MagickImage();
  label.BackgroundColor = new MagickColor("Khaki");
  label.Read("label:Magick.NET");
  // Resize the label to the width of the image and place the text in the center
  label.Extent(logo.Width, label.Height, Gravity.Center);
  images.Add(label);

  // Append the imagesusing (MagickImage output = images.AppendVertically())
  {
    output.Write("output-b.png");
  }
}

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>