title: How to prepare quality thumbnail image in c#
body: <p>I am developing the asp.net MVC application in c# language ,where I have given the facility to upload the image. I want to provide to crop the image and show its thumbnail. I bit achieve this by using System.Drawing.Bitmap namespace and its classes but it impacts the quality of the thumbnail while compress. What I have to do . I gone through this <a href="http://forums.asp.net/p/1320309/3676591.aspx" rel="nofollow">link</a></p>
  
  <p>but could not catch up much. please help.
  <strong>Edited:</strong>
  I had tried before to apply above link: and my code was :</p>
  
  <p>public static void ResizeAndSaveHighQualityImage(System.Drawing.Image image, int width, int height, string pathToSave, int quality)
      {</p>
  
  <pre><code>    // the resized result bitmap
  
      using (Bitmap result = new Bitmap(width, height))
      {
  
          // get the graphics and draw the passed image to the result bitmap
  
          using (Graphics grphs = Graphics.FromImage(result))
          {
  
              grphs.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
  
              grphs.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
  
              grphs.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
  
              grphs.DrawImage(image, 0, 0, result.Width, result.Height);
  
          }
          // check the quality passed in
  
          if ((quality &lt; 0) || (quality &gt; 100))
          {
  
              string error = string.Format("quality must be 0, 100", quality);
  
              throw new ArgumentOutOfRangeException(error);
  
          }
  
  
  
          EncoderParameter qualityParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
  
          string lookupKey = "image/jpeg";
  
          var jpegCodec = ImageCodecInfo.GetImageEncoders().Where(i =&gt; i.MimeType.Equals(lookupKey)).FirstOrDefault();
  
  
  
          //create a collection of EncoderParameters and set the quality parameter
  
          var encoderParams = new EncoderParameters(1);
  
          encoderParams.Param[0] = qualityParam;
  
          //save the image using the codec and the encoder parameter
  
          result.Save(pathToSave, jpegCodec, encoderParams);
  
      }
  
  }
  </code></pre>
  
  <p>this is generating low quality image as well. also I could not get much from above given link. why i  need to write handler there? is that necessary ?</p>