Metadata-Version: 2.4
Name: MLMediaCompressor
Version: 0.1.2
Summary: ML-based image and video compression library with CLI
Author-email: Nitin Baranwal <nitinkumarbaranawal@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Nitin
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scikit-learn
Requires-Dist: opencv-python
Requires-Dist: Pillow
Dynamic: license-file

# MLMediaCompressor

Image/Video compression using **KMeans clustering**.  
This library reduces the color complexity of images by clustering pixel values into a limited palette, producing visually compressed images with fewer colors.

---

## 🚀 Installation

You can install directly from GitHub:

```bash
pip install git+https://github.com/1Nitin1/MLMediaCompressor.git

```
# Usage
```python
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:

```bash
# 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
- url (str): Path to the input image file.

- n_colors (int): Number of colors (clusters) to reduce to. Default = 50.

- **Only for image** quality (int): JPEG quality (1–95). Default = 50.

- saveas (str): Output filename (without extension). Default = "compressed_image".

## Returns:

- A PIL.Image.Image object representing the compressed image.
- A mp4 file representing the compressed video.

# 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

# Development
Clone the repo and install dependencies:
```bash
git clone https://github.com/yourusername/MLMediaCompressor.git
cd MLMediaCompressor
pip install -r requirements.txt
```
# Contributing
- Pull requests are welcome!
- 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.
