This project has moved and is read-only. For the latest updates, please go here.

Annotating Images - Labeling Below (or Above) an Image

May 15, 2015 at 7:05 AM

First, I would like to thank MagickImage team for the amazing effort and the great functionality this environment is providing.

I am new to the MagickImage, Magick.NET specifically. I am interested to start by appending some text to the image as a footer. I don't want the text to overlay the image, but I want the text to be appended to the bottom as an extra portion. I tried to search on how to do that in .NET, but unfortunately I could not find the way. I saw how to so using the command line, but I need some help in doing the same in .NET environment. The command line that I saw is as follows:

convert dragon.gif -background Khaki label:'Faerie Dragon' \
      -gravity Center -append    anno_label.jpg

I am asking for your help in applying the same in .NET code.

I appreciate your help.

May 15, 2015 at 1:32 PM
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 height
using (MagickImage image = new MagickImage("logo:"))
  image.Extent(image.Width, image.Height + 20, Gravity.North, new MagickColor("Plum"));
  image.Annotate("Magick.NET", Gravity.South);

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

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

  // Append the images
  using (MagickImage output = images.AppendVertically())
May 17, 2015 at 5:53 AM
Thank you very much for your answer. I have used the second approach and it does what I exactly need.