π΅π± Polska wersja
A command-line tool for converting images, documents and audio files. Supports single file and batch directory processing.
pip install pillow typer tqdm pypandoc pymupdf pydub ffmpeg-python
pypandocrequires Pandoc to be installed.
pydubandffmpeg-pythonrequire FFmpeg to be installed and available in system PATH.
HEIC support requirespip install pillow-heif.
RAW support requirespip install rawpy.
You can run the tool using Docker without installing dependencies on your host system.
Build the image:
docker build -t cli-converter .This is the easiest way to use the tool. It guides you through the process:
docker run --rm -it -v "$(pwd):/data" cli-converter interactiveWhen prompted for a file, you can just type myimage.png if it's in your current folder.
docker run --rm -v "$(pwd):/data" cli-converter image convert -i input.png -o output.jpg --width 800 --grayscaledocker run --rm -v "$(pwd):/data" cli-converter audio batch -i music_folder -o mp3_output --format mp3 --bitrate 320kdocker run --rm -v "$(pwd):/data" cli-converter doc convert -i report.docx -o report.txtdocker run --rm -v "$(pwd):/data" cli-converter video convert -i movie.mp4 -o smaller_movie.mkv --resolution 720p --codec h265If you have all dependencies installed locally:
The tool features an interactive prompt for guided conversions without remembering flags:
python main.py interactiveAfter a successful conversion, the tool will display the statistics showing space saved or increased during the process with color-coded terminal text.
# Single conversion
python main.py image convert -i photo.png -o photo.jpg
# Batch conversion
python main.py image batch -i ./photos -o ./output --format webp| Flag | Short | Description | Default |
|---|---|---|---|
--input |
-i |
Input file | (required) |
--output |
-o |
Output file | (optional, prompts if omitted) |
--quality |
-q |
Quality (0β100) | 95 |
--height |
-h |
Height in pixels | None |
--width |
-w |
Width in pixels | None |
--grayscale |
-g |
Convert to grayscale | False |
--keep |
-k |
Keep aspect ratio | False |
--optimize |
-O |
Optimize file size | False |
--rotate |
-r |
Rotation in degrees (β360β360) | 0 |
--overwrite |
-v |
Overwrite existing file | False |
--delete |
-d |
Delete source file after conversion | False |
Supported formats: .png .jpg .jpeg .webp .heic .raw
Supported conversions:
| From \ To | PNG | JPG/JPEG | WEBP | HEIC | RAW |
|---|---|---|---|---|---|
| PNG | β | β | β | β | β |
| JPG/JPEG | β | β | β | β | β |
| WEBP | β | β | β | β | β |
| HEIC | β | β | β | β | β |
| RAW | β | β | β | β | β |
Cross-category conversions (e.g. image β document) are not allowed.
Validation rules:
- Input file must exist
- Output file extension must be a supported image format
- If output file already exists, use
--overwriteto replace it - Input and output paths cannot be the same unless
--overwriteis used - Height and width must be positive integers when provided
- HEIC files require the
pillow-heifpackage - RAW files require the
rawpypackage
# Single conversion
python main.py doc convert -i file.pdf -o file.txt
# Batch conversion
python main.py doc batch -i ./documents -o ./output --format txt| Flag | Short | Description | Default |
|---|---|---|---|
--input |
-i |
Source document path | (required) |
--output |
-o |
Target document path | (optional, prompts if omitted) |
--overwrite |
-v |
Overwrite existing file | False |
Supported formats: .pdf .docx .txt .odt
Supported conversions:
| From \ To | DOCX | TXT | ODT | |
|---|---|---|---|---|
| β | β | β | β | |
| DOCX | β | β | β | |
| TXT | β | β | β | |
| ODT | β | β | β |
β οΈ Exporting to PDF requires a PDF engine installed on your system (e.g. MiKTeX, wkhtmltopdf).
Validation rules:
- Input file must exist
- PDF input can only be converted to TXT (other targets will raise an error)
- Exporting to PDF requires an external PDF engine; if missing, a descriptive error is shown
- Cross-category conversions (e.g. document β image) are not allowed
- If output file already exists, use
--overwriteto replace it
# Single conversion
python main.py audio convert -i track.mp3 -o track.wav
# Batch conversion
python main.py audio batch -i ./music -o ./output --format flac| Flag | Short | Description | Default |
|---|---|---|---|
--input |
-i |
Source audio path | (required) |
--output |
-o |
Target audio path | (optional, prompts if omitted) |
--bitrate |
-b |
Output bitrate | 192k |
--channels |
-c |
Number of channels (1 or 2) | 2 |
--samplerate |
-s |
Sample rate in Hz | 44100 |
--gain |
-g |
Gain adjustment in dB (β30β+30) | 0 |
--trim |
-t |
Trim from start in milliseconds | 0 |
--overwrite |
-v |
Overwrite existing file | False |
Supported formats: .mp3 .wav .ogg .flac
Supported conversions:
| From \ To | MP3 | WAV | OGG | FLAC |
|---|---|---|---|---|
| MP3 | β | β | β | β |
| WAV | β | β | β | β |
| OGG | β | β | β | β |
| FLAC | β | β | β | β |
Validation rules:
- FFmpeg must be installed and available in PATH
--bitratemust be one of:128k,192k,256k,320k--sampleratemust be one of:16000,22050,44100,48000--channelsmust be1(mono) or2(stereo)--gainmust be betweenβ30and+30dB
# Single conversion
python main.py video convert -i movie.mp4 -o movie.avi --resolution 1080p --fps 60
# Batch conversion
python main.py video batch -i ./videos -o ./output --format mkv --codec h265| Flag | Short | Description | Default |
|---|---|---|---|
--input |
-i |
Source video path | (required) |
--output |
-o |
Target video path | (optional, prompts if omitted) |
--bitrate |
-b |
Video bitrate (e.g., 5000k) | 5000k |
--resolution |
-r |
Target resolution (e.g., 720p, 1080p) | 1080p |
--fps |
-f |
Frames per second (24β120) | 30 |
--codec |
-x |
Video codec (h264, h265, vp9, av1) | h264 |
--audio-bitrate |
-ab |
Audio bitrate (64kβ320k) | 192k |
--audio-channels |
-ac |
Audio channels (1 or 2) | 2 |
--overwrite |
-v |
Overwrite existing file | False |
Supported formats: .mp4 .avi .mkv .mov
Supported conversions:
| From \ To | MP4 | AVI | MKV | MOV |
|---|---|---|---|---|
| MP4 | β | β | β | β |
| AVI | β | β | β | β |
| MKV | β | β | β | β |
| MOV | β | β | β | β |
Validation rules:
- FFmpeg must be installed and available in PATH
- Resolution must be in range
[240, 2160]p - FPS must be between
24and120 - Supported codecs:
h264,h265,vp9,av1 - Audio bitrate must be in range
[64, 320]k - Audio channels must be
1or2 - If output file already exists, use
--overwriteto replace it - Cross-category conversions (e.g. audio β image) are not allowed
cli-converter/
βββ cli/
β βββ commands.py # CLI logic and sub-apps
β βββ display.py # Terminal UI and progress bars
β βββ __init__.py
βββ converter/
β βββ audio_processor.py # Pydub logic
β βββ base_processor.py # Shared media base class
β βββ docs_processor.py # Pandoc/Fitz logic
β βββ image_processor.py # Pillow logic
β βββ video_processor.py # FFmpeg logic
β βββ __init__.py
βββ utils/
β βββ file_handler.py # Path and extension validation
β βββ __init__.py
βββ main.py # Entry point
βββ README.md # English documentation
βββ README.pl.md # Polish documentation