Metadata-Version: 2.1
Name: maskilayer
Version: 1.0.1
Summary: Python tool to composite two images using multiple mask images
Home-page: https://github.com/twardoch/maskilayer
Author: Adam Twardoch
Author-email: adam+github@twardoch.com
License: Apache-2.0
Project-URL: Source, https://github.com/twardoch/maskilayer
Project-URL: Tracker, https://github.com/twardoch/maskilayer/issues
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
License-File: LICENSE.txt
Requires-Dist: numpy
Requires-Dist: Pillow
Requires-Dist: aiofiles
Requires-Dist: fire
Requires-Dist: rich
Provides-Extra: testing
Requires-Dist: setuptools; extra == "testing"
Requires-Dist: pytest; extra == "testing"
Requires-Dist: pytest-cov; extra == "testing"

# maskilayer

## Python tool to composite two images using multiple mask images

Maskilayer is a simple image compositing tool that allows you to blend two images using multiple mask images. It provides a flexible and efficient way to create complex image compositions. 

Uses `numpy` and `Pillow`.

## Features

- Composite two images using one or more mask images
- Support for both positive and negative masks
- Mask normalization with adjustable levels
- Asynchronous image writing for improved performance
- Command-line interface for easy use

## Installation

You can install maskilayer using pip:

```
pip install maskilayer
```

## Usage

### CLI usage

Use `maskilayer` from the command line:

```bash
maskilayer --back background.png --comp overlay.png --out output.png --masks mask1.png;mask2.png --imasks inverted_mask.png --norm 2 --verbose
```

CLI docs

```text
maskilayer
INFO: Showing help with the command 'maskilayer -- --help'.

NAME
    maskilayer - Composite two images using mask(s).

SYNOPSIS
    maskilayer <flags>

DESCRIPTION
    Composite two images using mask(s).

FLAGS
    -b, --back=BACK
        Type: str
        Default: ''
        layer 0 (background image path)
    -c, --comp=COMP
        Type: str
        Default: ''
        layer 1 (overlay image path that will be composited via masks)
    -o, --out=OUT
        Type: str
        Default: ''
        output composite image
    -s, --smask=SMASK
        Type: str
        Default: ''
        path to save the final mask (optional)
    -m, --masks=MASKS
        Type: Optional
        Default: None
        ;-separated mask image paths (optional)
    -i, --imasks=IMASKS
        Type: Optional
        Default: None
        ;-separated negative mask image paths (optional)
    -n, --norm=NORM
        Type: int
        Default: 0
        perform mask normalization with level 0-4
    -v, --verbose=VERBOSE
        Type: bool
        Default: False
        print additional output
    -f, --fast=FAST
        Type: bool
        Default: False
        save fast but larger files
```

### Code usage

Or import it in your Python code:

```python
from pathlib import Path
from maskilayer import comp_images

comp_images(
    background=Path("background.png"),
    overlay=Path("overlay.png"),
    output=Path("output.png"),
    masks=[Path("mask1.png"), Path("mask2.png")],
    invert_masks=[Path("inverted_mask.png")],
    normalize_level=2,
    verbose=True
)
```

## License

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