High quality image thumbnails in asp .net using Imageresizer

In my recent project there was a requirement to generate thumbnails from large images with custom height and width options. I have generated image thumbnails in my previous projects but the code I was using does not have option to define height.  So I decided to look for other options. Luckily I found Imageresizer. I tried Imageresizer and I am very impressed by its results as it generates High quality image thumbnails without losing image quality and moreover it meets my other requirements too (I can now define height and width of the thumbnails.) . 

It is very easy to implement imageresizer in your website:
 
Step1: Create a new asp .net website.
 
Step2: Install Image resize in your website. To install imageresizer in asp .net I found nuget as the easiest way however you can also download and Install Imageresizer from github. You can run following command in nuget package manager console to install ImageResizer:
 
PM> Install-Package ImageResizer
 
For more information about how to install packages from nuget you can refer this article:
 
Step3: Create new page in your website and add following controls:
1) File Upload control. 
2) Button.
3) Image. (To display generated thumbnail).
Page source will look like this:
 
   
Select Image
 
Generated Thumb
 
 
Step4: Write code to generate thumbnails from selected image on button click event:
 
protected void btnImageUpload_Click(object sender, EventArgs e)
    {
        foreach (string fileKey in HttpContext.Current.Request.Files.Keys)
        {
            HttpPostedFile file = HttpContext.Current.Request.Files[fileKey];
            if (file.ContentLength <= 0) continue; //Skip unused file controls.
            ImageResizer.ImageJob i = new ImageResizer.ImageJob(file, "~/uploads/" + file.FileName, new ImageResizer.ResizeSettings("width=100;height=100;format=jpg;mode=max"));
            i.CreateParentDirectory = true; //Auto-create the uploads directory.
            i.Build();

            //--- show image thumbnail on page
            imgGeneratedThumb.ImageUrl = "~/uploads/" + file.FileName;
        }
    }
 
 
Note: You can also rename thumbnails during uploading. For more info refer this article:
 
 
You can see how easily we can use imageresizer in asp .net to create high quality image thumbnails.  Imageresizer is a very vast plugin having many more options. Simple example to give random and unique names to thumbnails:
 
 
ImageResizer.ImageJob i = new ImageResizer.ImageJob(file, "~/uploads/.", new ImageResizer.ResizeSettings("width=100;height=100;format=jpg;mode=max"));
 
           
You can read full documentation at:
http://imageresizing.net/
I would like to thanks ImageResizer Team to develop such a wonderful plugin.
 

 Final Output


High-Quality-image-thumbnails-in-asp-net

We are nothing without our users ! You can help us offer even more high quality content. Please share our page !
Best quality Asp .Net Ajax Control Toolkit tutorials.

Give your valuable comments.

Name
Email
Comment
5 + 1 =
 
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2019 CodingFusion
75 Important SQL Server queries you should know