Does anyone have a good example of converting an image file coming from a HttpPostedFileBase to a reduced size and then converting the image to base64? I've spent hours on this with out any luck. Here is the start of my code. Some of which is hardcoded (image size).
This is giving me a black image when I place the base64 in an image tag and view it in a browser.
public ActionResult Upload(HttpPostedFileBase file, decimal? id, decimal? id2)
{
Image img = Image.FromStream(file.InputStream, true, true);
var bitmap = new Bitmap(img.Width - 100, img.Height - 100);
System.IO.MemoryStream stream = new System.IO.MemoryStream();
bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] imageBytes = stream.ToArray();
string base64String = Convert.ToBase64String(imageBytes);
InsertImage(base64String);
}
I'm asking how to change the image then convert it to base64. This is more specific than the question called it duplicate.