1

I am making a plugin and what I want to do is display a preview of image in widget. I have previews saved as SVG files. I found a way to show it in plugin window but I must convert them to PNG first. Is there any easy way to convert from SVG to PNG in python/pyqgis?

I found something about cairo, but I don't get how to use it in my plugin code. Anyone can help?

0

1 Answer 1

1

Use below code to use the cairo library

$ python3
import cairosvg
cairosvg.svg2pdf(url='image.svg', write_to='image.pdf')

reference : http://cairosvg.org/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.