Ask Your Question
0

Change default resolution in batch PNG conversion

asked 2016-04-25 09:52:53 +0200

lifelion gravatar image

updated 2016-04-25 09:56:11 +0200

Hello,

I am looking for a way to change the resolution of PNG generated by libreoffice without user interaction.

Here is an example

>> echo "example of PNG conversion" > example.txt
>> libreoffice --convert-to png example.txt

>> eog example.png # eye of gnome to display the file

The image generated by libreoffice from a A4 document has only 794 x 1123 pixels. (With 96 points per 2.54 cm, 21 x 29.7 cm is 793.7 x 1122.5, this is ok.)

I have tried with no luck several options to change the output resolution like:

>> libreoffice --convert-to png:writer_png_Export:resolution=300 example.txt

Maybe I could edit a file somewhere to change the output resolution from 96 to 300 DPI?

Thank you. Michael

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-04-26 08:53:02 +0200

lifelion gravatar image

updated 2016-04-26 16:58:49 +0200

I may have found why 96 is selected by default in the code.

In: ./svtools/source/filter/GraphicExportOptionsDialog.cxx

    GraphicExportOptionsDialog::GraphicExportOptionsDialog(vcl::Window* pWindow, const Reference<XComponent>& rxSourceDocument) :
        ModalDialog(pWindow, "GraphicExporter", "svt/ui/GraphicExportOptionsDialog.ui"),
        mResolution(96.0),
        mRenderer(rxSourceDocument)
{ ...}

I do not clearly understand the syntax but mResolution(96.0) could explain why 96 is selected by default.

Update: I have replaced mResolution(96.0) by mResolution(300.0) and recompiled libreoffice. Now 300 DPI is selected by default but only in the interactive export window. I tried writing a macro to export file but the Export menu still requires user interaction to select export parameters.

An ugly work around is to use a pdf export and use imagemagick convert command:

echo "Example of PNG conversion" > example.txt
libreoffice --headless --convert-to pdf example.txt
convert -density 600 -trim example.pdf example.png
eog example.png
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-04-25 09:52:53 +0200

Seen: 899 times

Last updated: Apr 26 '16