douchen9855 2017-01-04 09:37
浏览 243
已采纳

SVG嵌入式图像仅在浏览器中显示

I have SVG files that are generated programmatically using Raphael.js. The Raphael output is written to the actual file using PHP. The SVGs contain an image embedded as Base64 encoded data. The files looks like this:

<svg height="644" version="1.1" width="740" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="overflow: hidden; position: relative; top: -0.583008px;" viewBox="0 0 740 644" preserveAspectRatio="xMidYMid meet">
<image x="185" y="161" width="370" height="370" preserveAspectRatio="none" xlink:href="data: image/png;base64,iVBORw [-- lots of Base64-Data --] ==" transform="matrix(1.3696,-0.3064,0.3064,1.3696,-391.7711,-44.4982)" style="" stroke-width="0.7125311771299471"></image>
<desc>Created with Raphaël 2.2.0</desc>
<defs></defs>
</svg>

Here is one example file: http://www.mybinaryromance.com/files/0.218636001483456524.svg

The images are correctly displayed in browsers (tested Firefox and Chromium on Ubuntu), however, in other applications (Ubuntu image viewer, GIMP, TCPDF...) the SVG is displayed empty. Why is that happening?

  • 写回答

1条回答 默认 最新

  • dongzhi5386 2017-01-04 11:53
    关注

    Try removing the space after data:. The URI syntax specification specifically disallows spaces in URIs. See section 2.4.3 of https://tools.ietf.org/html/rfc2396

    It may be that browsers are being lenient, but those other programs aren't.

    If that doesn't change anything, then it may just be that those programs do not support Data URIs in SVG <image>s.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失