| | |
| | | from qgis.PyQt.QtWidgets import * |
| | | from qgis.PyQt.QtXml import * |
| | | |
| | | |
| | | def finished(): |
| | | img = render.renderedImage() |
| | | # QgsProject.instance().homePath() |
| | | image_location = os.path.join("e:/", "render.png") |
| | | # save the image; e.g. img.save("/Users/myuser/render.png","png") |
| | | img.save(image_location, "png") |
| | | |
| | | |
| | | QgsApplication.setPrefixPath("C:/Program Files/QGIS 3.16/bin", True) |
| | | qgs = QgsApplication([], True) |
| | |
| | | # page.setPageSize('A4') |
| | | # collection.addPage(page) |
| | | |
| | | layoutView = QgsLayoutView() |
| | | layoutView.setPreviewModeEnabled(True) |
| | | layoutView.setContentsMargins(0, 0, 0, 0) |
| | | layoutView.setCurrentLayout(layout) |
| | | # layoutView = QgsLayoutView() |
| | | # layoutView.setPreviewModeEnabled(True) |
| | | # layoutView.setContentsMargins(0, 0, 0, 0) |
| | | # layoutView.setCurrentLayout(layout) |
| | | |
| | | # project.layoutManager().addLayout(layout) |
| | | # map = QgsLayoutItemMap(layout) |
| | | # map.zoomToExtent(iface.mapCanvas().extent()) |
| | | |
| | | exporter = QgsLayoutExporter(layout) |
| | | img_path = os.path.join("e:/", "render.png") |
| | | img_path = os.path.join("E:/terrait/TianJin/LFServer/QGIS", "render.png") |
| | | exporter.exportToImage(img_path, QgsLayoutExporter.ImageExportSettings()) |
| | | |
| | | qgs.exitQgis() |