ML-based image and video compression library with CLI
Project description
MLMediaCompressor
ML‑based image and video color complexity compression library with CLI support.
Features
-
Image compression using KMeans color quantization
-
Video compression (frame‑wise KMeans)
-
Automatic .mov → .mp4 conversion for compatibility
-
CLI support for quick usage from terminal
🚀 Installation
You can install directly using pip:
pip install MLMediaCompressor
Usage
from MLMediaCompressor import compress_image, compress_video
# Compress image
compress_image("input.png", n_colors=12, saveas="output")
# Compress video
compress_video("input.mov", n_colors=16, saveas="output_video")
🖥️ Command-Line Usage
After installing, you can run the compressor directly from the terminal:
# Image compression
mlcompress image input.png --n_colors 12 --quality 80 --saveas out
# Video compression (MOV auto-converts to MP4)
mlcompress video input.mov --n_colors 16 --saveas out
Parameters
Common (Image & Video)
-
path (str): Path to the input file.
- For images: supported formats like .png, .jpeg.
- For videos: supported formats .mp4 and .mov (MOV is auto‑converted to MP4).
-
n_colors (int): Number of color clusters (KMeans) to reduce to. Default = 50 for images, 20 for videos.
-
saveas (str): Output filename (without extension)
- Default = "compressed_image" for images
- Default = "compressed_video" for videos.
Image‑specific
- quality (int): JPEG quality (1–95). Default = 50.
- Only applies when saving compressed images.
Returns:
- A PIL.Image.Image object representing the compressed image.
- A mp4 file representing the compressed video.
Contributing
- github: https://github.com/1Nitin1/MLMediaCompressor
- Fork, branch, PR workflow
- For major changes, please open an issue first to discuss what you’d like to change.
License
This project is licensed under the MIT License — see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mlmediacompressor-0.1.3.tar.gz.
File metadata
- Download URL: mlmediacompressor-0.1.3.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7576821d52a1c37c9dab0f9efe4297e0f607f480d2065ed561a8b0d44ec87cb
|
|
| MD5 |
c977ed23ba3d88d1a4c9349eebb95a73
|
|
| BLAKE2b-256 |
1f04e96f40297e641aaea21757bef0bcf215821404bf232d624bc0fd93fcf0ad
|
File details
Details for the file mlmediacompressor-0.1.3-py3-none-any.whl.
File metadata
- Download URL: mlmediacompressor-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
398961a0329241aa126571ca45451a1cc1001819c0874a681be8c6eb0360f9ff
|
|
| MD5 |
2bf31cbed636c5b592cadf75282e8ae1
|
|
| BLAKE2b-256 |
b1fe0bc490c989778b2067b26ff14708141b9f2903812fb8783480cdbcd6340e
|