Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Run in QGIS
# Save all the layouts as PNG files from the current project.
outurl = '/Users/USERNAME/' # using ~ does not work?
outformat = '.png'
outdpi = 200
manager = QgsProject.instance().layoutManager()
for layout in manager.printLayouts():
print('Saving: ' + layout.name())
layout = manager.layoutByName(layout.name())
exporter = QgsLayoutExporter(layout)
legendExporter=QgsLayoutExporter(layout)
imageSettings=legendExporter.ImageExportSettings()
imageSettings.cropToContents=True
imageSettings.dpi=outdpi
legendExporter.exportToImage(outurl + layout.name() + outformat,imageSettings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.