How to convert gif images to jpeg in c# code winforms? -


i trying convert gif/png images jpeg after want pass these images sqldatabase. because crystal report doesnot support gif images displaying report.

so have problem covert gif images jpeg.

sample code:

data = file.readallbytes(imgpath); 

data byte[] type have image path want convert jpeg before readallbytes() callls

i tried :

   using (image img = image.fromfile(imgpath))    {              img.save(imgpath, system.drawing.imaging.imageformat.jpeg);    } 

but got generic error gdi came. thanks.

this code:

        byte[] imagebuffer;          using (image img = image.fromfile(@"c:\temp_10\sample.gif"))         using (memorystream ms = new memorystream())         {             img.save(ms, imageformat.jpeg);             imagebuffer = ms.toarray();         }          //write fs (if need...)         file.writeallbytes(@"c:\temp_10\sample.jpg", imagebuffer); 

the namespace use system.drawing

i've modified code, think don't need file on filesystem can use byte array call crystal report


Comments