You cannot convert them during the upload. You have to let the user upload the image file, then you can try to load it into a Bitmap object and resave the image in a new format.
I'ved used code similar to this to do what you're describing before:
public static class ImageExtensions
{
public static byte[] ToByteArray(this Bitmap sourceImage, ImageFormat format)
{
if (sourceImage == null)
return null;
using (MemoryStream targetStream = new MemoryStream())
{
sourceImage.Save(targetStream, format);
targetStream.Close();
return targetStream.ToArray();
}
}
public static Bitmap ToBitmap(this byte[] bytes)
{
if (bytes == null)
return (Bitmap)null;
using (MemoryStream targetStream = new MemoryStream(bytes))
{
return new Bitmap(targetStream);
}
}
}
You can convert a Bitmap to an array of bytes in any image format you want. Then it's a simple matter to convert the array back to a Bitmap.