0

i am saving image into database as binary format, and while retrieving i am converting that binary format into image file and displaying.

byte[] picbin = (byte[])(binary data in datbase);
ImageConverter ic = new ImageConverter();
System.Drawing.Image img = (System.Drawing.Image)ic.ConvertFrom(picbin);`

and saving img- variable into some folder, by giving some name. but now i need to able to provide "downloadable option" to the user for that particular image in any one format, so that user can verify it so what is the way to implement this.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
Ray
  • 188
  • 2
  • 17
  • Any reason you don't want to just serve it in the original format? Do users *really* need different formats? – Jon Skeet Sep 07 '15 at 10:12

1 Answers1

0

To convert image to different format:

// Save the image in JPEG format.
img.Save(@"C:\test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

// Save the image in GIF format.
img.Save(@"C:\test.gif", System.Drawing.Imaging.ImageFormat.Gif);

// Save the image in PNG format.
img.Save(@"C:\test.png", System.Drawing.Imaging.ImageFormat.Png);    

Check How to: Convert Images from One Format to Another

SiD
  • 511
  • 4
  • 15