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
I updated from 4 to 7, because my old library was throwing an SEHException that I couldn't navigate around. I was hoping the update had fixed the issue. With the update, I ran into changes in the library code. Below I've outlined the problem areas. Any help would be appreciated.

Font, FillColor, StrokeColor and TextGravity no longer exist in the following. I'm having trouble finding where it was changed in the change logs.
using (MagickImage image = new MagickImage("xc:black", settings))
{
    image.Format = MagickFormat.Png;
    image.Font = "Arial";
    image.FillColor = new MagickColor("gray");
    image.StrokeColor = new MagickColor("red");
    image.BackgroundColor = new MagickColor("black");
    // Center text vertically
    image.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);
}
How do I set the image's Gamma? In the following I used to use image.Gamma()
public static void AdjustColor(MagickImage image, ImageDTO dto)
{
    image.BrightnessContrast(new Percentage(dto.Brightness), new Percentage(dto.Contrast));
    image.Gamma(dto.Gamma);
    image.Evaluate(Channels.Red, EvaluateOperator.Add, dto.Red);
    image.Evaluate(Channels.Green, EvaluateOperator.Add, dto.Green);
    image.Evaluate(Channels.Blue, EvaluateOperator.Add, dto.Blue);
}
I had
PixelCollection pixels = image.GetReadOnlyPixels();
and changed it to
PixelCollection pixels = image.GetPixels();
I hope this works.

Also the name of MagickResourceLimiteErrorException has changed in the following. Is there a new name, or does the library no longer throw it?
try
{
    using (MagickImage image = new MagickImage(file.FullName))
        colors = GetColorsOfImage(image);
}
catch (MagickResourceLimitErrorException)
{
    FileInfo thumbLocation = ImageThumb.ThumbLocation(file, true);
    using (MagickImage image = new MagickImage(thumbLocation.FullName))
        colors = GetColorsOfImage(image);
}

Viewing all articles
Browse latest Browse all 3693

Trending Articles



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