将图像转换为base64的工具(tool to convert images to base64)
我可以下载到我的Windows机器上的任何可用工具,我可以使用它将图像转换为基础64图像? 我正在使用visual studio 2010并试用这个插件,但我不能让它工作(不能得到图像的基础64的选项),不幸的是因为我真的喜欢它的工作方式。
我更喜欢本地的东西,而不是上传到网站,让他们转换图像。
any tools available that I can download to my windows machine that 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.
最满意答案
如果您有Visual Studio,为什么不拼凑一个可以为您执行此操作的快速应用程序?
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; }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; }更多推荐
发布评论