title: Returning Image using Image.FromStream
body: <p>I know there are similar posts but I haven't got any answer for my problem and hence posting this. </p>
  
  <p>I have a method that retrieves and returns image from a image path. Below is the code snippet I used. This fails in some cases as the image is lost after returning. </p>
  
  <pre><code>public static Image GetImageFromPicPath(string strUrl)
  {
      WebResponse wrFileResponse;
      wrFileResponse = WebRequest.Create(strUrl).GetResponse();
      using (Stream objWebStream = wrFileResponse.GetResponseStream())
      {
          return Image.FromStream(objWebStream);
      }
  }
  </code></pre>
  
  <p>If I use Bitmap class and return the image, metadata is lost.</p>
  
  <p>If I use MemoryStream (as shown below) and I don't dispose MemoryStream it works . But there is possible memory leak here. If I use using block, the image is lost. </p>
  
  <pre><code>MemoryStream ms = new MemoryStream();
  objWebStream.CopyTo(ms, 8192);
  return System.Drawing.Image.FromStream(ms); 
  </code></pre>
  
  <p>Can someone suggest me best approach to solve this issue.</p>
  
  <p>Thanks in advance!!</p>