title: A generic error occurred in GDI+ when resizing image in MemoryStream
body: <p>I am using <a href="http://imageprocessor.org/" rel="nofollow noreferrer">ImageProcessor</a> to process images in my website.</p>
  
  <p><strong>I have this resize function</strong>:</p>
  
  <pre><code> public Image ResizePhoto6version(Image img, int width, int height)
      {
          using (var ms = new MemoryStream())
          {
              using (var imgf = new ImageFactory(false))
              {
                  imgf.Load(img)
                      .Resize(new ResizeLayer(new Size(width, height), ResizeMode.Max))
                      .Save(ms);
  
                  return Bitmap.FromStream(ms);
              }
          }
      }
  </code></pre>
  
  <p><strong>In the webservice, I run this code</strong>:</p>
  
  <pre><code>MemoryStream ytSmallStream = new MemoryStream();
  MemoryStream ytMediumStream = new MemoryStream();
  System.Drawing.Image ytSmallThumb = null;
  System.Drawing.Image ytMediumThumb = null;
  
  ytSmallThumb.Save(ytSmallStream, ImageFormat.Jpeg);
  ytSmallStream.Position = 0;
  
  ytMediumThumb.Save(ytMediumStream, ImageFormat.Jpeg);
  ytMediumStream.Position = 0;
  </code></pre>
  
  <p>I get <strong>an exception</strong> when it reached the Save function ytSmallThumb.Save():</p>
  
  <pre><code>A generic error occurred in GDI+
  </code></pre>
  
  <p>The image is returned correctly from ResizeThumbnailToSmall function and the Stream has information of the image with the right size.</p>