【问题标题】:convert images in html file to base64 using C#使用 C# 将 html 文件中的图像转换为 base64
【发布时间】:2019-01-31 12:31:08
【问题描述】:

我有一个 html 文件,我想使用 C# 将其图像从本地源转换为 base64。

<img width=83 height=100
  src="Untitled_files/image001.png" alt="cid:image003.png@01D3405F.B71FED30"
  v:shapes="Picture_x0020_1">

如果您能帮助我,我们将不胜感激。

【问题讨论】:

标签: c# html image base64


【解决方案1】:

读取文件的字节,然后将其转换为base64:

byte[] imageArray =  System.IO.File.ReadAllBytes(@"image path");
string base64 = Convert.ToBase64String(imageArray);

如果文件不是本地文件,则需要download it

【讨论】:

  • 当我制作base64字符串时,我应该用图像路径替换它?
  • 如何在 html 文件中找到图片路径?
  • @یـوسـفنـیـری 这与您在 OP 中提出的问题不同。请再问一个问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多