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

How to generate images with formatted text

Jun 3, 2013 at 1:49 PM
Edited Jun 3, 2013 at 1:50 PM
Dim img As ImageMagick.MagickImage = New MagickImage(path)
img.Draw(New DrawableFont("Comic Sans MS", FontStyleType.Italic, FontWeight.Weight400, FontStretch.Normal))
img.Draw(New DrawableFillColor(New MagickColor(10, 10, 10)))
img.Draw(New DrawableText(50, 15, "Shafi"))

The code above is generating image, but text is drawing as plain text only, the DrawableFont and DrawableFillColor is not at all reflecting.

Can someone help me out, I want to generate formatted text based Images.
Jun 3, 2013 at 10:46 PM
Edited Jun 3, 2013 at 10:52 PM
If you want to do multiple draw operations you should use the overload of Draw that accepts an IEnumerable<DrawableBase>. Below is an example in C#.
using (MagickImage img = new MagickImage(path))
    List<DrawableBase> drawables = new List<DrawableBase>();
    drawables.Add(new DrawableFont("Comic Sans Is Evil", FontStyleType.Italic, FontWeight.Weight400, FontStretch.Normal));
    drawables.Add(new DrawableFillColor(new MagickColor(10, 10, 10)));
    drawables.Add(new DrawableText(50, 15, "Shafi"));
Jun 4, 2013 at 7:38 AM
Hi dlemstra,

Thanks for your quick reply. Your reply helped me greatly. Thanks again for your support.

By the way - you puzzled me by referring the font "Comic Sans" as Evil. :)