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

New Post: Updated from 4 to 7, have some issues

$
0
0
So I changed "The Font, FillColor settings are now set with the Settings property of MagickImage." But the image doesn't look the same anymore. Here's the code as it stands now:
MagickReadSettings settings = new MagickReadSettings();
settings.Width = ThumbSizeDTO.Size.Width;
settings.Height = ThumbSizeDTO.Size.Height;

using (MagickImage image = new MagickImage("xc:black", settings))
{
    image.Format = MagickFormat.Png;
    // If no PointSize set, image will be as wide as can be
    image.Settings.Font = "Arial";
    image.Settings.FillColor = new MagickColor("gray");
    image.Settings.StrokeColor = new MagickColor("red");
    image.BackgroundColor = new MagickColor("black");
    // Center text vertically
    image.Settings.TextGravity = Gravity.Center;

    // Build label
    StringBuilder sb = new StringBuilder("label:");
    // If directory name <= 20
    if (dirInfo.Name.Length <= 20)
    {
        sb.Append(dirInfo.Name);
        sb.Append("\n");
    }
    sb.Append("No Images");
    image.Read(sb.ToString());

    image.Write(dirThumbLocation);
}
It used to display an image like this:
Image
Now they look like this:
Image

Ignore the size difference, I probably changed the thumb size between when the two images were made. Notice, the text used to be on a black background and centered.

By changing BackColor to be
image.Settings.BackgroundColor = new MagickColor("black");
Image
I did get the background to be black, but the Gravity setting is still being ignored. Of note, you can still set the BackgroundColor to black without the Settings property of the image, it has no effect anymore at least for text.

Viewing all articles
Browse latest Browse all 3693

Trending Articles