blob: 7261dc5b691a66a90fae8998602cc65ec1e4081f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/usr/bin/env python3
import PyQt5.QtGui as QtGui
import PyQt5.QtWidgets as QtWidgets
import io
import subprocess
import sys
class SvgObject():
def __init__(self, file: str):
self.file=file
def render(self, dpi:int) -> QtGui.QImage:
try:
rawDataProc = subprocess.Popen(['rsvg-convert', '--dpi-x', str(dpi),
'--dpi-y', str(dpi), self.file],
stdout=subprocess.PIPE)
except:
QtWidgets.QMessageBox.about(None,'rsvg-convert missing','Please install rsvg-convert version >= 2.40 in your path.')
sys.exit(-1)
return QtGui.QImage.fromData(rawDataProc.stdout.read(), 'PNG')
|