decode base64 svg data to a svg file
我有一个文件,其中包含一个以base64编码的svg图像(data-uri)。该文件以
开头
data:image / svg xml; base64,PHN ....
如何在Linux中将其解码为.svg文件?
您可以在现代浏览器的网址栏中复制/粘贴字符串(包括
您可以使用在线base64解码器,例如http://www.base64decode.org/
要解决OP问题:
How to decode this to a .svg file in linux ?
由于linux默认具有python,因此我建议使用python脚本。
这是一个有效的示例:
1 2 3 4 5 6 7 8 9 10 | import base64 #change"YOURFILE" with the name of your original file with open("YOURFILE","rb") as f: encoded = f.read() encoded = encoded.replace("data:image/svg+xml;base64,","") decoded = base64.b64decode(encoded) #change"NEWFILE" with the name that you want to give your new svg with open("NEWFILE.svg","wb") as f: f.write(decoded) |
如果您是python的新手,只需将上面的代码复制粘贴到具有
1 | python aaabbb.py |
您可以使用例如
我使用SVG在线解码器,快速,简单
https://base64.online/decoders/decode-base64-to-svg
或者您可以使用在线工具
http://www.hosting4free.info/Base64Decode/Base64-Decode.jsp