title: Parameter is not valid when getting image from stream
body: <p>I have this code:</p>
  
  <pre><code>              MemoryStream ms = new MemoryStream(newbytes, 0,
              newbytes.Length);
                ms.Position = 0;      
          ms.Write(newbytes, 0, newbytes.Length);
                Image img = Image.FromStream(ms);
              img.Save(@"C:\Users\gsira\Pictures\Blue hills5.jpg");
  </code></pre>
  
  <p>I get this error at the Image.FromStream(ms) call:</p>
  
  <p>System.ArgumentException: Parameter is not valid.
     at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateIma</p>
  
  <p>How can I resolve this? A couple of links which solve this problem (one on an MSDN thread) are broken so I am lost.</p>