I'm attempting to follow along with this tutorial on using web images as markers within QGIS. I'm using static web-linked images, not webcams as in the tutorial.
The code seems to be working correctly, except the svg that is generated does not render within QGIS.
This is the code i'm using in the symbology function editor, taken from the above tutorial:
import requests
import base64
@qgsfunction(args='auto', group='Custom')
def show_camera(feed, feature, parent):
svg = """
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g>
<image xlink:href="data:image/jpeg;base64,{0}" />
</g>
</svg>
"""
data = requests.get(feed, stream=True).content
name = feed[-16:]
b64response = base64.b64encode(data)
newsvg = svg.format(b64response).replace('\n','')
path = r"C:\test\{0}.svg".format(name)
with open(path, 'w') as f:
f.write(newsvg)
return path.replace("\\", "/")
When I attempt to open the generated svg file directly in a browser, it also does not render, just showing me a blank page.
Any suggestions? Are there any better methods to use images as markers within QGIS in the 2 years since this tutorial was posted?