tool to convert images to base64
any tools available that I can download to my windows machine tha开发者_开发技巧t I can use to convert images to base 64 images? I am working with visual studio 2010 and tried this plugin but I cant get it working (dont get the option to get base 64 of image) unfortunately as I really like the way its suppose to work.
I would prefer something locally than uploading to a website and letting them convert the images.
If you have Visual Studio why not toss together a quick app which can do this for you?
public string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
// Convert Image to byte[]
image.Save(ms, format);
byte[] imageBytes = ms.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
return base64String;
}
}
public Image Base64ToImage(string base64String)
{
// Convert Base64 String to byte[]
byte[] imageBytes = Convert.FromBase64String(base64String);
MemoryStream ms = new MemoryStream(imageBytes, 0,
imageBytes.Length);
// Convert byte[] to Image
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
return image;
}
I know it's an old question, I suggest CodVerter: https://codverter.com/src/imagetobase64
Looks like it would be an easy fix for your issue.
精彩评论