making thumbnails from original images using c sharp asp net

 

Making thubnails using C# is very easy. All you need is to make use of .Net class libraries System.Drawing, System.Drawing.Imaging and System.Drawing.Drawing2D. Here is the code that makes thumbnail of the image supplied. The original image remains untouched. New thumb file is generated.

class ImageResize
{
        public static Bitmap MakeThumb(string ImagePath)
        {
            try
            {
                Image img = Image.FromFile(ImagePath);
                Bitmap b = new Bitmap(img, 150, 120);
      // You are use any width, height here. for now width=150, height=120 pixels
                return b;
            }
            catch (Exception exc)
            {
                return (new Bitmap(1, 1));
      // in case of any error, we are returning a thumbnail of 1 x 1 pixels
            }
        }
 }

Thanks

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading








Quality & Affordable Web Development | About the Author | Hosted By Windows Hosting | Discuss With Experts At Webmaster Forums