我有时会遇到“假” SVG,即仅将像素列为path
s 的 SVG 图像文件:
<svg xmlns="http://www.w3.org/2000/svg" width="1295" height="573">
<path fill="#FEFEFE" d="M143 1h1V0h-1Zm0 0" />
<path fill="#FFF" d="M144 1h33V0h-33Zm0 0" />
<path fill="#FEFEFE" d="M177 1h1V0h-1Zm0 0" />
<path fill="#FFF" d="M178 1h67V0h-67Zm0 0" />
<path fill="#FEFEFE" d="M245 1h1V0h-1Zm0 0" />
<path fill="#FFF" d="M246 1h12V0h-12Zm0 0" />
<path fill="#FEFEFE" d="M258 1h1V0h-1Zm0 0" />
<path fill="#FFF" d="M259 1h1036V0H259ZM0 2h180V1H0Zm0 0" />
<path fill="#FEFEFE" d="M180 2h1V1h-1Zm0 0" />
<path fill="#FFF" d="M181 2h10V1h-10Zm0 0" />
<path fill="#FEFEFE" d="M191 2h1V1h-1Zm0 0" />
<path fill="#FFF" d="M192 2h92V1h-92Zm0 0" />
...
不用说,存储和下载这些文件的成本是不必要的,所以我想识别这些文件并将它们转换为 PNG。
我该如何才能最好地识别这些伪造的 SVG?