Image resizing for large images, but for smaller images

I need to find a .NET solution for ASP.Net where larger images are reduced, but smaller images will be centered on a newer image on a white background. Any thoughts or help are appreciated.

+3
source share
3 answers

ImageResizer supports this:

<img src="image.jpg?width=500&height=300&mode=pad&scale=canvas" />

You can also adjust the background color with &bgcolor=color|hexor use &format=pngto get it in transparency.

+2
source

ImageMagick ( ) , , . , , .NET . , , Google .NET, , , .

0

( # 2 - ) http://www.codeproject.com/Articles/2941/Resizing-a-Photographic-image-with-GDI-for-NET , , ( ) .net System.Drawing.

ImageMagick:

convert input.png -resize 150x150 -background white -compose Copy -gravity center -extent 150x150 -quality 92 output3.png

but I found that ImageMagickNet, the ImageMagick shell for .Net, is not updated and there is no documentation for some commands; I will learn how to resize and resize an image, but I cannot find how to set the background color, gravity and other configurations. There is a discussion on the CodePlex page, but very few answers (http://imagemagick.codeplex.com/)

ImageMagickNET.MagickNet.InitializeMagick();
ImageMagickNET.Image img = new ImageMagickNET.Image("c:\\images\\input.png");
ImageMagickNET.Geometry geometry = new ImageMagickNET.Geometry("150x150");
img.Resize(geometry);
img.Compose(CompositeOperator.CopyCompositeOp);
img.Extent(geometry);
img.Write("c:\\images\output.png");

There are some tricks to make ImageMagickNET run, but you can easily find them on codeplex or stackoverflow. Therefore, my advice: go to System.Drawing!

0
source

All Articles