[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`.
``` shell
$ leanify-many *.jpg *.png *.gif
```
If not, you can tell it by setting the `LEANIFY` environment variable to the path of the binary
``` shell
$ 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`.
Without the `checked_pass` feature enabled, the top command will cause all subprocesses to silently error, since `0` is not a valid argument for `--max_depth`. The same is true of any invalid arguments passed to `--passthrough`.
The other aliases, however, make these checks for validity before starting the subprocesses.
If you want to pass something 'as is' to the subprocesses, do not enable the `checked_pass` feature flag when building, and pass the args with `--passthrough` instead of using the aliases. Alternatively, if the `checked_pass` feature was enabled when the binary was compiled (check the output of `--help`, and see below for features legend), pass `-P` instead of `-p` or `--passthough`.