title: Resize of image as array of bytes
body: <p>I am currently trying to resize an image to a thumbnail, to show as a preview when its done uploading. I am using fineuploader plugin for the uploading part of the image. I consistently keep getting a "parameter is not valid". I've seen many posts related to this, and tried most of the solution, but have no success. Here is the snippet of the code:</p>
  
  <pre><code>    public static byte[] CreateThumbnail(byte[] PassedImage, int LargestSide)  
      {  
          byte[] ReturnedThumbnail = null;  
  
          using (MemoryStream StartMemoryStream = new MemoryStream(),  
                              NewMemoryStream = new MemoryStream())  
          {  
              StartMemoryStream.Write(PassedImage, 0, PassedImage.Length); //error being fire in this line 
  
              System.Drawing.Bitmap startBitmap = new Bitmap(StartMemoryStream);  
  
              int newHeight;  
              int newWidth;  
              double HW_ratio;  
              if (startBitmap.Height &gt; startBitmap.Width)  
              {  
                  newHeight = LargestSide;  
                  HW_ratio = (double)((double)LargestSide / (double)startBitmap.Height);  
                  newWidth = (int)(HW_ratio * (double)startBitmap.Width);  
              }  
              else 
              {  
                  newWidth = LargestSide;  
                  HW_ratio = (double)((double)LargestSide / (double)startBitmap.Width);  
                  newHeight = (int)(HW_ratio * (double)startBitmap.Height);  
              }  
  
              System.Drawing.Bitmap newBitmap = new Bitmap(newWidth, newHeight);  
  
              newBitmap = ResizeImage(startBitmap, newWidth, newHeight);  
  
              newBitmap.Save(NewMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);  
  
              ReturnedThumbnail = NewMemoryStream.ToArray(); 
          }  
  
          return ReturnedThumbnail;  
      }  
  </code></pre>
  
  <p>I'm out of ideas, any help is appreciated.</p>