Quickly exporting all layouts from QGIS

Once you’ve made a whole bunch of beautiful maps in QGIS, you can click the ‘Export as image’ button (or PDF) and save a version of the map to disk. Doing so for more than a few of these is really tedious – for example, if you’ve had to add or update elements of a layer that’s common to a set of maps, you have to go through about 12 clicks per map to save ’em.

The script below will loop through and export all of the layouts in the current project, writing a PNG file (change ‘outformat’  to JPG if you like) at 200DPI.