Resize images using Image Processor in asp.net c#

By: Mihir
Updated: October 1, 2016 | Technology: Asp.Net, Asp.Net MVC
Resize images using Image Processor in asp.net c#

What is it Image Processor?

Image Processor is contain many libraries which is written in Asp.Net C#. it is also known as media processor. in which you can easily manipulate images using Asp.Net 4.5+ in C#. It has multiple methods to manipulates images, it uses Image Factory class.

Problems with Resigning Images:

I have developed a project in Umbraco cms and I want to display only one image in multiple pages with vary in sizes. In the image folder, I saved an image with different size. For example,

TestImage_200x200.jpg, TestImage_400x400.jpg

but this is not a proper way.

The solution with Image Processor Library:

I have found out a solution to resize an only single image in different in sizes. I have Install ImageProcessor in my application.

You can download ImageProcessor libraries via Nuget because its simplest and fastest way to install it.

Image Processor

ImageProcessor generally uses extension is called ImageProcessor.web that allow you to manipulation of images via Url API of query string parameters. And ImageProcessor.The Web uses an ImageProcessingModule class that provides various methods to perform some functions using a query string.

Resize image:

You can resize image in a different dimension with excellent quality to size ratio there are six different types of methods are available as follows.

  • Pad (default)
  • BoxPad
  • Crop
  • Min
  • Max
  • Stretch

You have to pass following parameters to resize image as follows:-

[code] <img scr=”~/Images/banner.jpg?width=300&height=300″ alt=”Banner Image” />
<img scr=”~/Images/banner.jpg?width=300&height=300&mode=crop” alt=”Banner Image” />[/code]

Provided Methods:

  • Resize, Rotate, Rounded Corners, Flip
  • Crop, Watermark, Filter, Saturation,
  • Brightness, Contrast, Quality, Format,
  • Vignette, Gaussian Blur, Gaussian Sharpen, and Transparency.

Example:

Original Image:

resize image by image processor in asp net 1

Resize Crop:

resize image by image processor in asp net 2

Conclusion:

Using Parameter like width, height, mode and anchor we can resize image easily using ImageProcessor in Asp.Net C#.

Click Here to know more smart tricks and tips related to ASP.NET MVC C# programming.