Resizing Image

This blog is about resizing the image. It is not good idea if you have image of 1600*1024 size and you want to display that image in 100*100 size. We have one option to make this image with 100 * 100 size and display that image instead of regular image. So low size image can increase the performance and also good quality of image.

Now, I am directly taking you towards the code

I have uploaded one .cs file just download that and put in the app_code folder.

And whenever you want to resize image resize that with following code.

if (!System.IO.File.Exists(Server.MapPath("../thumb/" + fileName)))

{

    Thumbnail objthumb = new Thumbnail();

    string resizedimage = objthumb.ResizeImage("../OriginalFile/" + fileName, 190, 190, "../ thumb /" + fileName);

}

1st args original file name

2nd args  new file's needed height

3rd args  new file's needed width

4th args  new file's location

And it will create new image at given location with given height and width.

Ebook Download
View all
Learn
View all