title: Saving as jpeg from memorystream in c#
body: <p>I have a method as shown below to save image as jpeg. 
  I want to save all the pictures with the same height and width without it getting distorted.</p>
  
  <p>How can I do that?
  Please help</p>
  
  <pre><code>public void SaveFileOnDisk(MemoryStream ms, string FileName)
  {
      try
      {
          string appPath = HttpContext.Current.Request.ApplicationPath;
          string physicalPath = HttpContext.Current.Request.MapPath(appPath);
          string strpath = physicalPath + "\\Images";
          string WorkingDirectory = strpath;
  
  
          System.Drawing.Image imgSave = System.Drawing.Image.FromStream(ms);
          Bitmap bmSave = new Bitmap(imgSave);
          Bitmap bmTemp = new Bitmap(bmSave);
  
          Graphics grSave = Graphics.FromImage(bmTemp);
          grSave.DrawImage(imgSave, 0, 0, imgSave.Width, imgSave.Height);
  
          bmTemp.Save(WorkingDirectory + "\\" + FileName + ".jpg");
  
  
          imgSave.Dispose();
          bmSave.Dispose();
          bmTemp.Dispose();
          grSave.Dispose();
      }
      catch (Exception ex)
      {
          //lblMsg.Text = "Please try again later.";
      }
  
  }
  </code></pre>