Created
March 15, 2019 15:20
-
-
Save simbamangu/53cf87a61e4092a38fb9611393a529a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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