Open Tylersuard opened 3 years ago
probably the error is in the encode part, have you checked the XML file, should be something like: "<image xlink:href="data:image/png;base64,B4s3G4str1ng...
I have used:
with open("small_electric.png", "rb") as image_file:
encoded_image = base64.b64encode(image_file.read())
encoded = encoded_image.decode()
I write an image, and it just shows up as a blank svg.
I'm using this code:
import svgwrite import base64 from wand.image import Image
dwg = svgwrite.Drawing('svgwrite-example1.svg', profile='tiny') img = Image(filename="small_electric.png")
image_data = img.make_blob(format='png') encoded = base64.b64encode(image_data).decode() pngdata = 'data:image/png;base64,{}'.format(encoded)
image = dwg.add(dwg.image(href=(pngdata)))
dwg.save()