re-pixel


Namere-pixel JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryA powerful image compression library with multiple algorithms and formats support
upload_time2025-08-06 14:43:23
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords image compression optimization jpeg png webp
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Re-pixel 🎨

[![PyPI version](https://badge.fury.io/py/re-pixel.svg)](https://badge.fury.io/py/re-pixel)
[![Python versions](https://img.shields.io/pypi/pyversions/re-pixel.svg)](https://pypi.org/project/re-pixel/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

**Re-pixel** is a powerful and versatile Python library for image compression that supports multiple formats and algorithms. It provides both a simple Python API and a feature-rich command-line interface for compressing images while maintaining optimal quality.

## ✨ Features

- **Multiple Format Support**: JPEG, PNG, WebP
- **Smart Compression**: Automatic quality optimization for target file sizes
- **Batch Processing**: Compress entire directories with progress tracking
- **Advanced Algorithms**: Multiple compression techniques including lossless options
- **CLI Interface**: Easy-to-use command-line tool with rich output
- **Flexible API**: Simple Python API for integration into your projects
- **Image Analysis**: Detailed image information and compression statistics
- **Resize & Compress**: Automatic resizing with aspect ratio preservation

## 🚀 Installation

### From PyPI (Recommended)

```bash
pip install re-pixel
```

### From Source

```bash
git clone https://github.com/rakshithkalmadi/re-pixel.git
cd re-pixel
pip install -e .
```

### Development Installation

```bash
git clone https://github.com/rakshithkalmadi/re-pixel.git
cd re-pixel
pip install -e ".[dev]"
```

## 📖 Quick Start

### Python API

```python
from repixel import ImageCompressor

# Initialize compressor
compressor = ImageCompressor()

# Compress a single image
result = compressor.compress(
    input_path="photo.jpg",
    output_path="photo_compressed.jpg",
    quality=80,
    format="jpeg"
)

print(f"Original size: {result['original_size_mb']:.2f} MB")
print(f"Compressed size: {result['compressed_size_mb']:.2f} MB")
print(f"Space saved: {result['space_saved_percent']:.1f}%")

# Batch compress all images in a directory
results = compressor.compress_batch(
    input_dir="photos/",
    output_dir="compressed_photos/",
    quality=85,
    format="webp",
    recursive=True
)

# Optimize quality for target file size
result = compressor.optimize_quality(
    input_path="large_photo.jpg",
    target_size_mb=2.0,
    format="jpeg"
)
```

### Command-Line Interface

```bash
# Compress a single image
re-pixel compress photo.jpg -q 80 -f webp -o photo_compressed.webp

# Batch compress images in a directory
re-pixel batch photos/ -o compressed/ -q 85 -f webp --recursive

# Find optimal quality for target size
re-pixel optimize large_photo.jpg --target-size 2.0 -f jpeg -o optimized.jpg

# Get image information
re-pixel info photo.jpg

# List supported formats
re-pixel formats
```

## 🔧 Advanced Usage

### Custom Compression Settings

```python
from repixel import ImageCompressor

compressor = ImageCompressor()

# JPEG with progressive encoding
result = compressor.compress(
    input_path="photo.jpg",
    output_path="optimized.jpg",
    quality=90,
    format="jpeg",
    optimize=True,
    progressive=True
)

# WebP lossless compression
result = compressor.compress(
    input_path="graphic.png",
    output_path="graphic.webp",
    format="webp",
    lossless=True
)

# PNG with color reduction
result = compressor.compress(
    input_path="image.png",
    output_path="compressed.png",
    quality=70,  # Affects color palette reduction
    compress_level=9
)
```

### Resize and Compress

```python
from repixel.algorithms import AdvancedCompressor

# Resize to fit within bounds and compress
result = AdvancedCompressor.resize_and_compress(
    input_path="high_res.jpg",
    output_path="web_optimized.jpg",
    max_width=1920,
    max_height=1080,
    quality=85,
    format="jpeg"
)
```

### Image Information

```python
from repixel.utils import get_image_info, format_file_size

info = get_image_info("photo.jpg")
print(f"Dimensions: {info['dimensions']}")
print(f"File size: {format_file_size(info['size_bytes'])}")
print(f"Format: {info['format']}")
print(f"Megapixels: {info['megapixels']} MP")
```

## 🎛️ CLI Reference

### Commands

- `compress` - Compress a single image
- `batch` - Compress multiple images in a directory
- `optimize` - Find optimal quality for target file size
- `info` - Display image information
- `formats` - List supported formats

### Common Options

- `-q, --quality` - Compression quality (1-100)
- `-f, --format` - Output format (jpeg, png, webp)
- `-o, --output` - Output path
- `--optimize` - Enable optimization
- `--progressive` - Enable progressive JPEG
- `--lossless` - Use lossless compression (WebP)
- `-v, --verbose` - Verbose output

### Examples

```bash
# High quality JPEG compression
re-pixel compress input.jpg -q 95 -f jpeg --progressive --optimize

# Batch convert to WebP with custom quality
re-pixel batch photos/ -o webp_photos/ -f webp -q 80 --recursive

# Optimize for web (target 500KB)
re-pixel optimize large.jpg --target-size 0.5 -f jpeg -o web_ready.jpg

# Get detailed image information
re-pixel info photo.jpg --verbose
```

## 📊 Format Comparison

| Format | Best For | Compression | Transparency | Animation |
|--------|----------|-------------|--------------|-----------|
| JPEG | Photos, complex images | Lossy, high | ❌ | ❌ |
| PNG | Graphics, simple images | Lossless | ✅ | ❌ |
| WebP | Web images, modern browsers | Both | ✅ | ✅ |

## 🎯 Quality Guidelines

- **95-100**: Maximum quality, minimal compression
- **85-95**: High quality, good for professional use
- **75-85**: Good quality, recommended for web
- **65-75**: Medium quality, smaller file sizes
- **50-65**: Lower quality, significant compression
- **Below 50**: Poor quality, maximum compression

## 🛠️ Development

For comprehensive development instructions, including building, testing, and installation methods, see [DEVELOPMENT.md](DEVELOPMENT.md).

### Setup Development Environment

```bash
git clone https://github.com/rakshithkalmadi/re-pixel.git
cd re-pixel
pip install -e ".[dev]"
```

### Run Tests

```bash
python -m pytest tests/ -v
```

### Code Formatting

```bash
black repixel/
flake8 repixel/
```

### Type Checking

```bash
mypy repixel/
```

## 📦 Building and Publishing

### Build the Package

```bash
python -m build
```

### Upload to PyPI

```bash
twine upload dist/*
```

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

### Development Setup

For detailed development instructions, see [DEVELOPMENT.md](DEVELOPMENT.md).

Quick start:
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Set up development environment (`pip install -e ".[dev]"`)
4. Run tests (`python -m pytest tests/ -v`)
5. Commit your changes (`git commit -m 'Add amazing feature'`)
6. Push to the branch (`git push origin feature/amazing-feature`)
7. Open a Pull Request

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- [Pillow](https://pillow.readthedocs.io/) for image processing capabilities
- [OpenCV](https://opencv.org/) for advanced image algorithms
- [Click](https://click.palletsprojects.com/) for the CLI interface

## 📞 Support

If you encounter any issues or have questions:

- 🐛 [Report bugs](https://github.com/rakshithkalmadi/re-pixel/issues)
- 💡 [Request features](https://github.com/rakshithkalmadi/re-pixel/issues)
- 📧 Contact: your.email@example.com

---

Made with ❤️ by [Rakshith Kalmadi](https://github.com/rakshithkalmadi)


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "re-pixel",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "image, compression, optimization, jpeg, png, webp",
    "author": null,
    "author_email": "Rakshith Kalmadi <rakshithkalmadi@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/06/07/a5bbb31d137be29cbd2ed20021c84822d628248a46a0fc07899c5c78d4fe/re_pixel-1.0.1.tar.gz",
    "platform": null,
    "description": "# Re-pixel \ud83c\udfa8\n\n[![PyPI version](https://badge.fury.io/py/re-pixel.svg)](https://badge.fury.io/py/re-pixel)\n[![Python versions](https://img.shields.io/pypi/pyversions/re-pixel.svg)](https://pypi.org/project/re-pixel/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n**Re-pixel** is a powerful and versatile Python library for image compression that supports multiple formats and algorithms. It provides both a simple Python API and a feature-rich command-line interface for compressing images while maintaining optimal quality.\n\n## \u2728 Features\n\n- **Multiple Format Support**: JPEG, PNG, WebP\n- **Smart Compression**: Automatic quality optimization for target file sizes\n- **Batch Processing**: Compress entire directories with progress tracking\n- **Advanced Algorithms**: Multiple compression techniques including lossless options\n- **CLI Interface**: Easy-to-use command-line tool with rich output\n- **Flexible API**: Simple Python API for integration into your projects\n- **Image Analysis**: Detailed image information and compression statistics\n- **Resize & Compress**: Automatic resizing with aspect ratio preservation\n\n## \ud83d\ude80 Installation\n\n### From PyPI (Recommended)\n\n```bash\npip install re-pixel\n```\n\n### From Source\n\n```bash\ngit clone https://github.com/rakshithkalmadi/re-pixel.git\ncd re-pixel\npip install -e .\n```\n\n### Development Installation\n\n```bash\ngit clone https://github.com/rakshithkalmadi/re-pixel.git\ncd re-pixel\npip install -e \".[dev]\"\n```\n\n## \ud83d\udcd6 Quick Start\n\n### Python API\n\n```python\nfrom repixel import ImageCompressor\n\n# Initialize compressor\ncompressor = ImageCompressor()\n\n# Compress a single image\nresult = compressor.compress(\n    input_path=\"photo.jpg\",\n    output_path=\"photo_compressed.jpg\",\n    quality=80,\n    format=\"jpeg\"\n)\n\nprint(f\"Original size: {result['original_size_mb']:.2f} MB\")\nprint(f\"Compressed size: {result['compressed_size_mb']:.2f} MB\")\nprint(f\"Space saved: {result['space_saved_percent']:.1f}%\")\n\n# Batch compress all images in a directory\nresults = compressor.compress_batch(\n    input_dir=\"photos/\",\n    output_dir=\"compressed_photos/\",\n    quality=85,\n    format=\"webp\",\n    recursive=True\n)\n\n# Optimize quality for target file size\nresult = compressor.optimize_quality(\n    input_path=\"large_photo.jpg\",\n    target_size_mb=2.0,\n    format=\"jpeg\"\n)\n```\n\n### Command-Line Interface\n\n```bash\n# Compress a single image\nre-pixel compress photo.jpg -q 80 -f webp -o photo_compressed.webp\n\n# Batch compress images in a directory\nre-pixel batch photos/ -o compressed/ -q 85 -f webp --recursive\n\n# Find optimal quality for target size\nre-pixel optimize large_photo.jpg --target-size 2.0 -f jpeg -o optimized.jpg\n\n# Get image information\nre-pixel info photo.jpg\n\n# List supported formats\nre-pixel formats\n```\n\n## \ud83d\udd27 Advanced Usage\n\n### Custom Compression Settings\n\n```python\nfrom repixel import ImageCompressor\n\ncompressor = ImageCompressor()\n\n# JPEG with progressive encoding\nresult = compressor.compress(\n    input_path=\"photo.jpg\",\n    output_path=\"optimized.jpg\",\n    quality=90,\n    format=\"jpeg\",\n    optimize=True,\n    progressive=True\n)\n\n# WebP lossless compression\nresult = compressor.compress(\n    input_path=\"graphic.png\",\n    output_path=\"graphic.webp\",\n    format=\"webp\",\n    lossless=True\n)\n\n# PNG with color reduction\nresult = compressor.compress(\n    input_path=\"image.png\",\n    output_path=\"compressed.png\",\n    quality=70,  # Affects color palette reduction\n    compress_level=9\n)\n```\n\n### Resize and Compress\n\n```python\nfrom repixel.algorithms import AdvancedCompressor\n\n# Resize to fit within bounds and compress\nresult = AdvancedCompressor.resize_and_compress(\n    input_path=\"high_res.jpg\",\n    output_path=\"web_optimized.jpg\",\n    max_width=1920,\n    max_height=1080,\n    quality=85,\n    format=\"jpeg\"\n)\n```\n\n### Image Information\n\n```python\nfrom repixel.utils import get_image_info, format_file_size\n\ninfo = get_image_info(\"photo.jpg\")\nprint(f\"Dimensions: {info['dimensions']}\")\nprint(f\"File size: {format_file_size(info['size_bytes'])}\")\nprint(f\"Format: {info['format']}\")\nprint(f\"Megapixels: {info['megapixels']} MP\")\n```\n\n## \ud83c\udf9b\ufe0f CLI Reference\n\n### Commands\n\n- `compress` - Compress a single image\n- `batch` - Compress multiple images in a directory\n- `optimize` - Find optimal quality for target file size\n- `info` - Display image information\n- `formats` - List supported formats\n\n### Common Options\n\n- `-q, --quality` - Compression quality (1-100)\n- `-f, --format` - Output format (jpeg, png, webp)\n- `-o, --output` - Output path\n- `--optimize` - Enable optimization\n- `--progressive` - Enable progressive JPEG\n- `--lossless` - Use lossless compression (WebP)\n- `-v, --verbose` - Verbose output\n\n### Examples\n\n```bash\n# High quality JPEG compression\nre-pixel compress input.jpg -q 95 -f jpeg --progressive --optimize\n\n# Batch convert to WebP with custom quality\nre-pixel batch photos/ -o webp_photos/ -f webp -q 80 --recursive\n\n# Optimize for web (target 500KB)\nre-pixel optimize large.jpg --target-size 0.5 -f jpeg -o web_ready.jpg\n\n# Get detailed image information\nre-pixel info photo.jpg --verbose\n```\n\n## \ud83d\udcca Format Comparison\n\n| Format | Best For | Compression | Transparency | Animation |\n|--------|----------|-------------|--------------|-----------|\n| JPEG | Photos, complex images | Lossy, high | \u274c | \u274c |\n| PNG | Graphics, simple images | Lossless | \u2705 | \u274c |\n| WebP | Web images, modern browsers | Both | \u2705 | \u2705 |\n\n## \ud83c\udfaf Quality Guidelines\n\n- **95-100**: Maximum quality, minimal compression\n- **85-95**: High quality, good for professional use\n- **75-85**: Good quality, recommended for web\n- **65-75**: Medium quality, smaller file sizes\n- **50-65**: Lower quality, significant compression\n- **Below 50**: Poor quality, maximum compression\n\n## \ud83d\udee0\ufe0f Development\n\nFor comprehensive development instructions, including building, testing, and installation methods, see [DEVELOPMENT.md](DEVELOPMENT.md).\n\n### Setup Development Environment\n\n```bash\ngit clone https://github.com/rakshithkalmadi/re-pixel.git\ncd re-pixel\npip install -e \".[dev]\"\n```\n\n### Run Tests\n\n```bash\npython -m pytest tests/ -v\n```\n\n### Code Formatting\n\n```bash\nblack repixel/\nflake8 repixel/\n```\n\n### Type Checking\n\n```bash\nmypy repixel/\n```\n\n## \ud83d\udce6 Building and Publishing\n\n### Build the Package\n\n```bash\npython -m build\n```\n\n### Upload to PyPI\n\n```bash\ntwine upload dist/*\n```\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n### Development Setup\n\nFor detailed development instructions, see [DEVELOPMENT.md](DEVELOPMENT.md).\n\nQuick start:\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Set up development environment (`pip install -e \".[dev]\"`)\n4. Run tests (`python -m pytest tests/ -v`)\n5. Commit your changes (`git commit -m 'Add amazing feature'`)\n6. Push to the branch (`git push origin feature/amazing-feature`)\n7. Open a Pull Request\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Acknowledgments\n\n- [Pillow](https://pillow.readthedocs.io/) for image processing capabilities\n- [OpenCV](https://opencv.org/) for advanced image algorithms\n- [Click](https://click.palletsprojects.com/) for the CLI interface\n\n## \ud83d\udcde Support\n\nIf you encounter any issues or have questions:\n\n- \ud83d\udc1b [Report bugs](https://github.com/rakshithkalmadi/re-pixel/issues)\n- \ud83d\udca1 [Request features](https://github.com/rakshithkalmadi/re-pixel/issues)\n- \ud83d\udce7 Contact: your.email@example.com\n\n---\n\nMade with \u2764\ufe0f by [Rakshith Kalmadi](https://github.com/rakshithkalmadi)\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A powerful image compression library with multiple algorithms and formats support",
    "version": "1.0.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/rakshithkalmadi/re-pixel/issues",
        "Homepage": "https://github.com/rakshithkalmadi/re-pixel",
        "Source Code": "https://github.com/rakshithkalmadi/re-pixel"
    },
    "split_keywords": [
        "image",
        " compression",
        " optimization",
        " jpeg",
        " png",
        " webp"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "020f2fd3f4ec85470459f360cb6b80165a62fcf3fb16f639462bad7047ad467d",
                "md5": "1ba9bea3cd48e76b19b598542846c2d6",
                "sha256": "a9883f1fa7ec77c2d6f1983745927f9800bc2c04e41f71c6bc6638304d1c36ce"
            },
            "downloads": -1,
            "filename": "re_pixel-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1ba9bea3cd48e76b19b598542846c2d6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 15845,
            "upload_time": "2025-08-06T14:43:22",
            "upload_time_iso_8601": "2025-08-06T14:43:22.303763Z",
            "url": "https://files.pythonhosted.org/packages/02/0f/2fd3f4ec85470459f360cb6b80165a62fcf3fb16f639462bad7047ad467d/re_pixel-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0607a5bbb31d137be29cbd2ed20021c84822d628248a46a0fc07899c5c78d4fe",
                "md5": "c3eb6082d1dafb89c65afd450d472dd5",
                "sha256": "77692d48c5c78d29aaf9c431ab2825692f44057b39884146342fd5a220a41c33"
            },
            "downloads": -1,
            "filename": "re_pixel-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c3eb6082d1dafb89c65afd450d472dd5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 19583,
            "upload_time": "2025-08-06T14:43:23",
            "upload_time_iso_8601": "2025-08-06T14:43:23.262101Z",
            "url": "https://files.pythonhosted.org/packages/06/07/a5bbb31d137be29cbd2ed20021c84822d628248a46a0fc07899c5c78d4fe/re_pixel-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-06 14:43:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rakshithkalmadi",
    "github_project": "re-pixel",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "re-pixel"
}
        
Elapsed time: 0.56939s