QGIS Print Composer has tool "Save As Image" and I found appropriate function in QGIS source code exportCompositionAsImage. Is it possible to get access to existing Print Composer from Python console and perform this operation - export composition as image with composer settings.
UPDATE #1: Thanks to @ndawson. I'm using
printPageAsRaster function for printing different combinations of layers created with layerCombinations plugin:
from layerCombinations import classFactory lc = classFactory(iface) lc_manager = lc.manager combinations = lc_manager.combinationsList composition = iface.activeComposers().composition() composition_items = composition.items() for cmb in combinations: for item in composition_items: if item.type() == 65641: #this is the type of ComposerMap lc_manager.applyCombinationToMap(cmb, item) image = composition.printPageAsRaster(0) image.save('/home/dr/' + cmb +'.png','png')