Bug 146904 - the default compression force of png image should be 9 into the image compression form
Summary: the default compression force of png image should be 9 into the image compres...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
7.2.5.2 release
Hardware: All All
: low enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Image-Compression-Dialog
  Show dependency treegraph
 
Reported: 2022-01-21 20:02 UTC by Jérôme
Modified: 2022-06-07 10:13 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jérôme 2022-01-21 20:02:24 UTC
The png form is a lossless compression format. The compression force should be the maximum compression (9) by default.
Comment 1 jan d 2022-02-18 22:00:56 UTC
Agree – I also wonder why it is not on (as it seems to be the standard in other apps, usually)
Comment 2 Timur 2022-02-19 15:10:46 UTC
If not explained differently, let's put to New as Enhancement.
Comment 3 Jérôme 2022-02-19 15:23:03 UTC
Perhaps could we think about simplying the dialog window : remove the compression force setting for png format and make it hard coded with the maximum force ?
Comment 4 Jérôme 2022-02-20 14:24:26 UTC
As a follow up of comment 3 I filed bug #147550.
Comment 5 Jérôme 2022-03-12 13:25:22 UTC
I think there is only one character to change near this line :

https://git.libreoffice.org/core/+/HEAD/svx/source/dialog/compressgraphicdialog.cxx#52

It seems we just have to change initialization of memParam.CompressionMF to 9.

struct memParam {
  bool ReduceResolutionCB = false;
  int  MFNewWidth = 1;
  int  MFNewHeight = 1;
  bool LosslessRB = true;
  bool JpegCompRB = false;
<  int  CompressionMF = 6;
>  int  CompressionMF = 9;
  int  QualityMF = 80;
  int  InterpolationCombo = 3;
};
Comment 6 Julien Nabet 2022-06-04 09:41:01 UTC
Jérôme: I tested your patch but on Draw, when trying to export in PNG, this code isn't called.

I gave a try, after some research the patch would be:
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 73b1acbe871d..6d02a96b984b 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -4570,7 +4570,7 @@
                   </info>
                 </maxInclusive>
               </constraints>
-              <value>6</value>
+              <value>9</value>
             </prop>
             <prop oor:name="Interlaced" oor:type="xs:int" oor:nillable="false">
               <!-- UIHints: File  Export  Filetype  PNG-Portable Network


Perhaps we should also modify the Jérôme's code location (which must be used somewhere) + https://opengrok.libreoffice.org/xref/core/svtools/source/filter/exportdialog.cxx?r=d3849255#791

    791         case FORMAT_PNG :
    792         {
    793             // Compression 1..9
    794             mxPNGCompression->show();
    795             sal_Int32 nCompression = mpFilterOptionsItem->ReadInt32("Compression", 6);
    796             if ( ( nCompression < 1 ) || ( nCompression > 9 ) )
    797                 nCompression = 6;
replace both "6" values by "9"
the goal would be to have a homogenous thing, not a "9" value by default in a case, and a "6" value in other cases.


Now I don't know if it's the right value to put I just can tell that Gimp uses "9" by default. Since it's the number 1 in open source world for raster images, I would trust their judgment.
However seeing some comments in https://bugs.documentfoundation.org/show_bug.cgi?id=147550, it seems some may disagree.

Heiko/Xisco: any thoughts here?
Comment 7 Julien Nabet 2022-06-04 09:52:30 UTC
I just found where's the code quoted by Jérôme is used.
- Open Writer
- insert an image
- right click on the image
- choose "Compress..."

I confirm its suggestion allows to change the default value for PNG compression to 9 here.
Comment 8 Heiko Tietze 2022-06-07 10:13:09 UTC
The struct memParam is just for holding user input during a session. The default needs to be set at both places, the struct and in the common.xcs file.

No opinion from my side what the best value is.