Base 64编码图像在浏览器中无法正常显示?

时间:2015-04-18 17:13:32

标签: html

我有一个基本64位编码字符串形式的png图像,但在html中无法正常显示。这是我的代码:



<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAACWCAYAAABkW7XSAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFi8AABYvARIm7xwAAB8jSURBVHhe7Z39zxzVdcfzdxCVgvoDbwk2kVCiGBLAAsIPRsYipUIOQUBDEIVAIAiKLGpFLiYCBxSICAKBQKYgiJGxFEghkYOABExqktLaAiMorQuE8mJhjMGw0/nM3bM7L3dm7szuzt47ez7S1T7P7rzcebnfOefcc+98IVIURQkEFSwleA4ciKJNmwbR2rWD6LbbBtHrrw9/UHqHCpYSNPv3R9Hllw+iL8R3spSjjx5Eb789XEDpFSpYStDccosRq3vvHSSW1vbtRrSuvnowXELpEypYSrA88YQRp+uuM2Il4Bby/a5dwy+U3qCCpQTJ7t1GrM46axDt3Tv8cghCxW933qlWVt9QwVKCA2vq0kuNFbVz5/DLFPy+ZMkgOvVUFay+oYKlBIe4gieeOEgsLRvEsFjmgw+GXyi9QAVLCQoECOsJMaK89NLwhxwE4fldUxz6hQqWEhSbN4/FikJag43HHjPLlQmaEiYqWAFB48RisJVFcH0Irn/lK2PBWrOmPEYlbiNpDkp/UMHyDBGlZ54xVsINNwyiM87IWhVVhUaMFdJHyyJvXSFKZahg9ZP4kirzhB4tuuERJwkUpwsWxbp1RrhohJTnn89aV3z30ENmufS6bK8vuUicpxNOMOJNKgPHVxZwBxWsfhJfUqVraHw0pA0bsgJDN/zddw+irVuNEOXzi1xh3Y0bx9tGzNhnyGBxciyMF+QT0apCBaufxJdU6QpyhhCkdBwGqwiBmsXYNywQyVdiv6GC2CJQnDcRLAS5ChWsfhJfUmWWYCUhSOLGUHDVcOvaWlBNICYmohVq4xXrCtE95hhzLHWuLlYly9kSS5VwiS+pMgvefddYAWJNIVgI1zx687DeqAPCFSJnnz1Icq8k6I7rXOfiikuMe6z0BxWsKYM4"/>
&#13;
&#13;
&#13;

如果您在浏览器中尝试此操作,则不会显示整个图像。我做错了什么?

1 个答案:

答案 0 :(得分:0)

由于此问题被标记为PHP,我们将审核一些可用于诊断问题的工具:

如果我们使用它来编写一个小帮助程序,我们会发现:

  • 预期图片尺寸为width="300" height="150"
  • 实际图片在内置Windows图片查看器中如下所示:

    Picture

这显然不是150垂直像素的数据。