Metadata-Version: 2.4
Name: MLMediaCompressor
Version: 0.1.3
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

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:

```bash
pip install MLMediaCompressor

```
# 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
### 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.
