diff --git a/README.md b/README.md new file mode 100644 index 0000000..8ccf06e --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +# optimg + +A tiny Python CLI/library wrapping the **JPEG** and **PNG** optimization file size. +It uses **jpegoptim** and **optipng** as optimization programs. + +> **NOTE** For now only **JPEG** optimization is available and **it's not loseless** ! It will set the JPEG size to a maximum of **1 Mb**. Thus, may reduce drastically the quality... Should be fixed in future release. + +## Install +Make sure **jpegoptim** and **optipng** are installed on your system and are available in your **PATH**. + +On Ubuntu: +```bash +sudo apt install jpegoptim optipng +``` + +Other system: +```bash +sudo consider-using-linux-quickly-or-die +``` + +Install the CLI in a dedicated environment: +```bash +make install +``` +It will install the CLI in a Python virtual env: `venv.dist`. + +Under your virtual environment: +```bash +optimg --help + +usage: optimg [-h] [--mimetype {JPEG,PNG}] [--size {TINY,MEDIUM,LARGE,FAT}] [--dest DEST] [--workers WORKERS] [--show] [--debug] src + +Optimize JPEG and PNG files from a directory. + +positional arguments: + src Directory path to scan. + +options: + -h, --help show this help message and exit + --mimetype {JPEG,PNG} + Filter by mimetype. Default is all. + --size {TINY,MEDIUM,LARGE,FAT} + Filter by file size. Default is all. + --dest DEST Base destination directory of optimized files. + --workers WORKERS Number of workers used to optimize files. + --show Details the directory by mimetypes and quit. + --debug Set log level to debug. Default is info. +``` + +You're good ! Enjoy ! + +## Examples + +* Optimize **JPEG** files of **MEDIUM** size: +```bash +optimg /my/path --size MEDIUM --mimetype JPEG + +[INFO] - 2025-10-22 12:30:30,209 - launching optimization (6145) for type: image/jpeg and size range: MEDIUM on 4 workers... +Optimizing...: 6%|██████▎ | 344/6145 [00:01<00:30, 193.12it/s +``` +> **NOTE** The default **base destination directory** is the **data** folder if you don't provide `--dest` optional argument. It will be automatically created in the current path where the CLI is launched. + +**ALL** the files path are preserved (sub-directory creation etc...). The **base destination directory** to put the files optimized elsewhere. +