jpegoptim-py
A python wrapper to provide a pip-installable jpegoptim binary.
Internally this package provides a convenient way to download the pre-built jpegoptim binary for your particular platform.
Installation
pip install jpegoptim-py
Usage
After installation, the jpegoptim
binary should be available in your
environment (or jpegoptim.exe
on windows).
As a pre-commit hook
See pre-commit for instructions
Sample .pre-commit-config.yaml
:
- repo: https://github.com/UnknownPlatypus/jpegoptim-py
rev: v1.5.5.1
hooks:
- id: jpegoptim
Lossy compression is not idempotent. In that case, consider adding a threshold, otherwise you might block the commit for too long.
Sample .pre-commit-config.yaml
with lossy compression enabled:
- repo: https://github.com/UnknownPlatypus/jpegoptim-py
rev: v1.5.5.1
hooks:
- id: jpegoptim
args: [ "--strip-all", "--all-progressive", "--max", "85", "--threshold", "4"]
References
This is an adaptation of shellcheck-py following the exact same strategy. This aims at making it easier to use as a pre-commit hook.