afernandez afernandez at odyhpc.com
Sun Feb 25 07:48:51 PST 2024
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 created file has a resolution of 3507 by 2480 pixels (not sure where
these figures come from but QGIS seems to always use them).
Hi afernandez,
I guess your layout is an A4 page (H 29.7 cm * W 21 cm) and that the
export resolution for the print layout is set to 300 dpi (the default
value). This explains way the exported image has dimension of H 3507 px
* W 2480 px and it's resolution is 300 dpi:
3507 px = 29.7 cm * 300 dpi * 1 in / 2.54 cm
canvas_settings.dpi = 100
The new file has a resolution of 1169x826 pixels
1169 px = 29.7 cm * 100 dpi * 1 in / 2.54 cm
You need to set the resolution to the value of 102.63 dpi in order to
obtain the H dimension of 1200 pixels:
102.63 dpi = 1200 px * 2.54 cm / 29.7 cm / 1 in
So you will obtain an image of 1200 px * 848 px
canvas_settings.imageSize = QSize(1200,750)
it just seems to ignore QSize and reverts back to a 3507x2480 resolution.
You need to respect the aspect ration of the layout page dimensions:
H / W layout = 29.7 cm / 21 cm = about 1.4143
W image = 1200 px / 1.4143 = 848 px
thus
canvas_settings.imageSize = QSize(1200, 848)
Best regards.
Andrea
_______________________________________________
QGIS-User mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user