Optimg is a command-line tool designed to optimise images for web use. It supports resizing, format conversion, and quality adjustment to help reduce file sizes while maintaining visual fidelity.
To install Optimg, you can use pip:
pip install optimgWithout any arguments, the tool will use default settings to optimise images in the current directory and save them to an out folder.
optimgYou can customize the optimisation process using various command-line options:
optimg -i path/to/images -o path/to/output --resize-mode c --max-res 1920 --format webp --quality 80 --losslessYou can disable resizing by setting --resize-mode to n (none):
optimg --resize-mode nFor more details on the available options, run:
optimg --helpNote that the --lossless option is only applicable when the output format is set to webp.
The quality parameter will then control the compression level for lossless webp images, where 100 is the most compression.
You can also run Optimg using Docker. First, build the Docker image:
docker run -v ./in:/in -v ./out:/out ghcr.io/davidohnee/optimg:main --resize-mode nOr use Docker Compose:
curl https://raw.githubusercontent.com/davidohnee/optimg/main/docker-compose.yml -o docker-compose.yml
docker compose up