Closed pschwientek closed 1 year ago
@pschwientek : Thanks for the PR! This worked for me with Python 3.10.2 and the following versions. I suggest also fixing the same issue for SVG, i.e.
--- a/treeview/main.py
+++ b/treeview/main.py
@@ -682,7 +682,7 @@
if ext == "SVG":
svg = QSvgGenerator()
targetRect = QRectF(0, 0, w, h)
- svg.setSize(QSize(w, h))
+ svg.setSize(QSize(int(round(w)), int(round(h))))
svg.setViewBox(targetRect)
svg.setTitle("Generated with ETE http://etetoolkit.org")
svg.setDescription("Generated with ETE http://etetoolkit.org")
@@ -749,10 +749,10 @@
scene.render(pp, targetRect, scene.sceneRect(), ratio_mode)
else:
targetRect = QRectF(0, 0, w, h)
- ii= QImage(w, h, QImage.Format_ARGB32)
+ ii= QImage(int(round(w)), int(round(h)), QImage.Format_ARGB32)
ii.fill(QColor(Qt.white).rgb())
- ii.setDotsPerMeterX(dpi / 0.0254) # Convert inches to meters
- ii.setDotsPerMeterY(dpi / 0.0254)
+ ii.setDotsPerMeterX(int(round(dpi / 0.0254))) # Convert inches to meters
+ ii.setDotsPerMeterY(int(round(dpi / 0.0254)))
pp = QPainter(ii)
pp.setRenderHint(QPainter.Antialiasing)
pp.setRenderHint(QPainter.TextAntialiasing)
This works with:
Python 3.10.2
ete3 3.1.2
PyQt5 5.15.6
PyQt5-Qt5 5.15.2
PyQt5-sip 12.9.0
I have come across the same issue and looking at your pull request i believe if you would just fix w and h variables after line 662 you will need even need to fix the dpi variable
fixed in 71d0d3b0f0d8e65a93af295a64a4860d2f79551c
the dimension conversion calculations yield float values but
QImage
expectsint
in constructor as well as.setDotsPerMeterX()
a quick fix is casting to
int()
but there are probably better ways