Convert Images into .png format

Posted by Sudhak under Silverlight on 5/6/2010 | Views : 5667 | Status : [Member] | Replies : 5
Hi,

How to convert image files any kind of images (jpeg,png,tiff,gig,bmp...) to .png format and store it into database?

Thanks
Sudha




Responses

Posted by: Caroline on: 4/9/2013 [Member] Starter | Points: 25

Up
0
Down
simple, i believe this image pragramme can help you . www.rasteredge.com/dotnet-imaging/image-convert/

Sudhak, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thomas128 on: 3/19/2014 [Member] Starter | Points: 25

Up
0
Down
If you want to convert your images to png, you might wannna try this: http://www.yiigo.com/guides/vbnet/how-to-convert.shtml
This imaging tool can help you convert between different image formats, like png, jpeg, gif, tiff, bmp, etc. Hope it'll help!

Today is a gift. That's why it's called the Present!

Sudhak, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 3/19/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
You can use the below code:-

converting any image to .png format.

using System.Drawing;

Bitmap b = (Bitmap)Bitmap.FromStream(file.InputStream);

using (MemoryStream ms = new MemoryStream()) {
b.Save(ms, ImageFormat.Png);

// use the memory stream to base64 encode..
}


See the link:-
http://stackoverflow.com/questions/17294737/converting-an-image-to-png-on-upload
http://stackoverflow.com/questions/3906260/how-can-i-convert-a-jpeg-image-to-a-png-one-with-transparent-background
http://stackoverflow.com/questions/6513633/convert-transparent-png-to-jpg-with-non-black-background-color

After converting the image, convert image to byte array.

FileStream FS = new FileStream(filepath, FileMode.Open, FileAccess.Read); //create a file stream object associate to user selected file 
byte[] img = new byte[FS.Length]; //create a byte array with size of user select file stream length
FS.Read(img, 0, Convert.ToInt32(FS.Length));//read user selected file stream in to byte array


See the links:-
http://stackoverflow.com/questions/4852558/how-to-save-image-to-a-database
http://www.codeproject.com/Articles/33310/C-Save-and-Load-Image-from-Database

Happy coding.

Sudhak, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response