Resizing an image using Magick.net

4.4k Views Asked by At

I've got an image that I want to resize using Magick.net before displaying in an ASP .Net page, but when I look at the displayed image in my browser, it comes up as a broken image.

Here's what my code would look like if I wasn't resizing:

this.LogoBox.Image = _myModel.LogoImage;

Here's what my ImageMagick-using code looks like:

var logoToDisplay = new MagickImage(new Bitmap(_myModel.LogoImage));
logoToDisplay.Resize(imageWidth, imageHeight);
this.LogoBox.Image = logoToDisplay.ToBitmap();

When I take out the second ...Resize... line, nothing comes up. I can't seem to find good documentation for Magick.net, even on the CodePlex site.

Any thoughts?

1

There are 1 best solutions below

0
On

When you use the ToBitmap method your image will be converted to Bmp. You probably want to use another image format, e.g. ImageFormat.Png or ImageFormat.Jpeg. Feel free to post a message here also: https://magick.codeplex.com/discussions. And can you also put up a link to the image you are trying to resize?