Ubuntu – How to set 7z compression level using GUI in Ubuntu

7ziparchivecompressionfile-rollergui

Archive Manager, or file-roller, doesn't seem to have the option to set the compression level for 7z files.

enter image description here

However, the windows client 7-zip has an option to do so using GUI –

enter image description here

On Ubuntu/Linux, one can set the compression level in the command line (CLI) using the -m flag. For details, refer to this answer.

Is there any provision for setting the compression level for 7z archives using GUI in Ubuntu?

Best Answer

My idea was to find some hint in the file listing of the packages or in gconf, but I had no luck. Someone else knew the answer though.

Superuser: Change default compression levels for file-roller?

Either:

$ dconf write /org/gnome/file-roller/general/compression-level "'maximum'"

Or:

$ dconf-editor
  1. Select org in the left-hand pane.
  2. Select gnome in the left-hand pane.
  3. Select file-roller in the left-hand pane.
  4. Select general in the left-hand pane.
  5. Select compression-level in the right-hand pane.
  6. Set compression-level to 'maximum'.

Unfortunately, you cannot fine-tune this setting for different compression programmes. If you want all the freedom, you can use your shell instead.

Image of dconf Editor with file-roller's compression-level set to maximum..

That answer previously had no upvotes, so I checked if this has any effect at all and choose to compress some documents with the default settings and with maximum settings (type 7z). Result: 2,3 KB improvement on a ~300 KB archive.

Caution:

  • Depending on the content it can have a negative impact to compress everything with LZMA/LZMA2 on level maximum. PNGs for example are already compressed with Deflate and won't gain much from compression. It would make more sense to optimize them with PNGOUT/OptiPNG, Zopfli and then archive them with LZ4, achieving faster archive decompression and reducing file size.

I tried to find out more through file-rollers manpage and user manual, still no luck. Then I dowloaded the source package and searched for "maximum" in fr-command-7z.c (note how I avoid to say I read the source), which gave me the following:

switch (archive->compression) {
case FR_COMPRESSION_VERY_FAST:
    fr_process_add_arg (command->process, "-mx=1");
    break;
case FR_COMPRESSION_FAST:
    fr_process_add_arg (command->process, "-mx=5");
    break;
case FR_COMPRESSION_NORMAL:
    fr_process_add_arg (command->process, "-mx=7");
    break;
case FR_COMPRESSION_MAXIMUM:
    fr_process_add_arg (command->process, "-mx=9");
    if (! _g_mime_type_matches (archive->mime_type, "application/zip")
        && ! _g_mime_type_matches (archive->mime_type, "application/x-cbz"))
    {
        fr_process_add_arg (command->process, "-m0=lzma2");;
    }
    break;
}

That's as far as I can currently get, it seems like there is no ultra setting.

Related Question