<div dir="ltr">Hi Nyall<br><div class="gmail_extra"><br><div class="gmail_quote">2018-05-25 1:58 GMT+02:00 Nyall Dawson <span dir="ltr"><<a href="mailto:nyall.dawson@gmail.com" target="_blank">nyall.dawson@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On 25 May 2018 at 03:02, DelazJ <<a href="mailto:delazj@gmail.com" target="_blank">delazj@gmail.com</a>> wrote:<br>
> Hi all,<br>
><br>
> I have a layout on which I checked the "save world file" option in Layout<br>
> --> Exports settings<br>
> When I export this layout to image, I'd expect it to generate a world file<br>
> next to it considering that the generateWorldFile is an attribute of the<br>
> ImageExportSettings class [0]. But no world file.<br>
<br>
</span>The GUI setting isn't stored in the layout*  - you need to manually<br>
set generateWorldFile to true<br>
in your ImageExportSettings if you want the world file created.<br>
<span><br>
<br>
> mylayout=QgsProject.instance()<wbr>.layoutManager().layoutByName(<wbr>'Composeur 1')<br>
> exporter = QgsLayoutExporter(mylayout)<br>
> exporter.exportToImage(filePat<wbr>h, QgsLayoutExporter.ImageExportS<wbr>ettings)<br>
<br>
</span>If you want the world file, this should be<br>
<br>
    exporter = QgsLayoutExporter(mylayout)<br>
    settings = QgsLayoutExporter.ImageExportS<wbr>ettings()<br>
    settings.generateWorldFile = True<br>
    exporter.exportToImage(filePat<wbr>h, settings)<br>
<span><br></span></blockquote><div>Unfortunately, in my real world use case,  I don't know whether the world file is desired. I'm updating my MapsPrinter plugin [0] which helps exporting multiple layouts at once.. So I should catch the selection the user made in the GUI. This leads me to use the customProperty:</div><div><br></div><div>
    exporter = QgsLayoutExporter(mylayout)<br>
    settings = QgsLayoutExporter.ImageExportS<wbr>ettings()<br>
    settings.generateWorldFile =

mylayout.customProperty('<wbr>exportWorldFile')</div><div><br></div><div>leading to this function [1] . It does seem to work but I realize that for svg particularly, I cannot have access to properties like RDF metadata nor layered SVG as they are proposed to the user only in the export process. I understand that there's some unstability in layout(?) customProperty API but would that be possible to have these options in the layout export settings frame or what are the plans regarding them (if any)?<br></div><div><br></div><div>Side note on the plugin I'm working on:</div><div>1/ I'm trying to count the number of pages that are actually exportable and use the following code:</div><div><br></div><div>        page_number, pagesToExport = 0, 0<br>        while page_number < layout.pageCollection().pageCount():<br>            if layout.pageCollection().shouldExportPage(page_number):<br>                pagesToExport += 1<br>        print(pagesToExport)<br></div><div><br></div><div>It seems that 
layout.pageCollection().shouldExportPage(page_number)

always return true. In a two pages layout, I checked the "Exclude page from export" option on one page and calling that returns true for both pages.  Exporting from GUI or code does however output only one page. Isn't that the right property to check?<br></div><div><br></div><div>2/ The count of pages was intended to help me display a progress bar for each processed page but while this is possible for simple export, it does not look like there's a way to catch when a page/feature is output in a atlas configuration. No signal emitted until the end of all the iterations, right?</div><div><br></div><div>Again, thanks Nyall for the help and for having simplified (afaict) the Python side of layout (despite all my questions - /me sunday Python learner)<br></div><div><br></div><div>Regards,<br></div><div>Harrissou<br></div><div><br></div><div>[0] <a href="https://github.com/DelazJ/MapsPrinter/tree/migration_to_v3">https://github.com/DelazJ/MapsPrinter/tree/migration_to_v3</a><br></div><div>[1] <a href="https://github.com/DelazJ/MapsPrinter/commit/1a1adbe6a8500abf5b738c4ec907ff7e02f364fb#diff-a5fa5f963eba950b6c361daae67e552fR670">https://github.com/DelazJ/MapsPrinter/commit/1a1adbe6a8500abf5b738c4ec907ff7e02f364fb#diff-a5fa5f963eba950b6c361daae67e552fR670</a><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>
<br>
> ls=QgsProject.instance().layou<wbr>tManager().layouts()<br>
> for elt in ls:<br>
>   exporter = QgsLayoutExporter(elt)<br>
>   imgSettings = exporter.ImageExportSettings()<br>
>   print(<a href="http://elt.name" rel="noreferrer" target="_blank">elt.name</a>(), imgSettings.generateWorldFile)<br>
><br>
> which returns False for any layout, including the one I checked the option<br>
> for. Btw, dpi returns -1.0, pages return an empty list... I guess I might<br>
> have missed something but...No idea.<br>
<br>
</span>That's because imgSettings here is a default constructed<br>
ImageExportSettings - which defaults to no world file, and dpi of -1<br>
(as noted in the docs, the dpi in ImageExportSettings is an override<br>
... if it's -1, then the layout's DPI will be used). An empty pages<br>
list means export all pages. You need to manually populate this<br>
ImageExportSettings as required for your export.<br>
<br>
Nyall<br>
<br>
<br>
* actually it is stored in a customProperty for the layout, but that's<br>
not part of stable API<br>
<br>
    layout.customProperty('exportW<wbr>orldFile')<br>
<span><br>
<br>
><br>
> [0]<br>
> <a href="https://qgis.org/pyqgis/master/core/Layout/QgsLayoutExporter.html#qgis.core.QgsLayoutExporter.ImageExportSettings" rel="noreferrer" target="_blank">https://qgis.org/pyqgis/master<wbr>/core/Layout/QgsLayoutExporter<wbr>.html#qgis.core.<wbr>QgsLayoutExporter.ImageExportS<wbr>ettings</a><br>
><br>
> Thanks for your help,<br>
> Harrissou<br>
><br>
</span>> ______________________________<wbr>_________________<br>
> Qgis-user mailing list<br>
> <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-user</a><br>
> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-user</a><br>
</blockquote></div><br></div></div>