<html><head></head><body><div>
<div dir="auto" id="compose-body-wrapper"><div dir="auto"><div
dir="auto">Hello,</div><div dir="auto">I'm using the image exporter to
create PNG files. Everything looks good but the files must have a
resolution of 1,200 pixels in the horizontal direction. The snippet
to create the image file reads:</div><div dir="auto">
exporter = QgsLayoutExporter(layout)</div><div dir="auto">
png_name = '/home/ubuntu/output/testing.png'</div><div
dir="auto"> exporter.exportToImage(png_name,
QgsLayoutExporter.ImageExportSettings())</div><div dir="auto">The created
file has a resolution of 3507 by 2480 pixels (not sure where these figures
come from but QGIS seems to always use them).</div><div dir="auto">When I
modify the snippet with </div><div dir="auto">
exporter = QgsLayoutExporter(layout)</div><div
dir="auto"> canvas_settings =
exporter.ImageExportSettings()</div><div dir="auto">
canvas_settings.dpi = 100</div><div dir="auto">
png_name = '/home/ubuntu/output/testing.png'</div><div
dir="auto"> exporter.exportToImage(png_name,
settings=canvas_settings)</div><div dir="auto">The new file has a
resolution of 1169x826 pixels (which is not very far from what I need).
However, and when I try a tighter control with:</div><div dir="auto">
exporter = QgsLayoutExporter(layout)</div><div
dir="auto"> canvas_settings =
exporter.ImageExportSettings()</div><div dir="auto">
canvas_settings.imageSize = QSize(1200,750)</div><div
dir="auto"> png_name =
'/home/ubuntu/output/testing.png'</div><div dir="auto">
exporter.exportToImage(png_name, settings=canvas_settings)</div><div
dir="auto">it just seems to ignore QSize and reverts back to a 3507x2480
resolution. I'm not sure how achieve a finer control over the output.
Thanks.</div><div dir="auto">P.S. QGIS is
v3.34 </div><div><br></div></div></div>
</div></body></html>