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

New Post: C# Replacing a transparent background with White

$
0
0
Hi,
I am trying to read an image file (which might be PNG, JPG,, or GIF) and, if it has a transparent background change the background to White, then resize it and writing it out as a GIF file while maintaining the highest quality possible.
I know the code below isn't quite right, I've tried various iterations but been unable to get the background color to change. Any help/suggestions appreciated.
Thanks
MagickImage img = new MagickImage(source);
img.BackgroundColor = new MagickColor(System.Drawing.Color.White);
MagickGeometry geometry = new MagickGeometry(width, height);
geometry.IsPercentage = false;
//geometry.IgnoreAspectRatio = false;
img.Quality = 100;
img.Resize(geometry);
img.Write(target);

Viewing all articles
Browse latest Browse all 3693

Trending Articles