You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
leanify-many/README.md

3.8 KiB

leanify-many

Spawn leanify as subprocesses to enable parallel & concurrent compression.

About

leanify is a nice tool that losslessly compresses files for you, it works on a large number of file types. However, it has a couple drawbacks; the main one is it is entirely single threaded, and each file blocks without letting the others also be operated on.

I'm too stupid to try to fork it and add concurrent processing myself, so I made this hack that just spawns child processes of leanify on the file-list instead. This means we can run leanify in parallel for a bunch of files easily, with options to set the max (or have no max) number of leanify operations allowed to happen at once.

This can greatly improve speed when using on multiple files.

How to use

Usually leanify-many can determine where leanify is installed by checking your PATH.

$ leanify-many *.jpg *.png *.gif

If not, you can tell it by setting the LEANIFY environment variable to the path of the binary

$ LEANIFY=~/bin/leanify leanify-many .

Changing number of children

By default, there is no limit to the number of children spawned. This can cause "too many open files" errors if used with a lot of files, and can also cause slowdowns when trying to spawn many more processes than the CPU has processors.

You can set the number of children with --max-children <number>, and/or you can pass -m to limit the max number of children to the number of processors the system currently has.

Recursion

leanify-many handles resolving pathnames before sending them to leanify, by default there is a max recursion depth of 1 (so, no recursion). Passing a directory instead of the list of files to leanify-many does not count towards this limit, so leanify-many dir/ and leanify-many dir/* are the same (except the files she shell excludes from *).

You can specify the max recursion depth with --recursive <number>, or set it to unlimited with -r.

Misc.

Option Description Notes
--no-progress Do not display progress bar Requires progress feature
--colour Always display colour Requires colour feature
--no-colour Never display colour Requires colour feature
- Treat all remaining arguments as inputs, stop parsing flags

Optional features

There are a few compile-time features that can be enabled/disabled for additional functionality.

Name Description Default
splash Show program information when printing help On
colour Enable colouring of certain outputs, like warnings On
progress Enable progress bar On
threads Enable threaded scheduler Off

When building with Rust nightly, some other optimisations and features will be present.

Legend

In --help the compiled-with features are listed as so:

  • +feature means feature enabled
  • -feature means feature disabled

When printing with colour:

  • Red means enabled by default
  • Bright red means enabled specifically
  • Blue means disabled by default
  • Bright blue means disabled specifically

Additional

I included a Gentoo ebuild for leanify in other

License

GPL'd with <3