Metadata-Version: 2.4
Name: maskstudio
Version: 0.1.1
Summary: Vector-first desktop mask annotation studio for batch image workflows.
Project-URL: Homepage, https://pypi.org/project/maskstudio/
Project-URL: Repository, https://github.com/reiarthur/maskstudio
Project-URL: Issues, https://github.com/reiarthur/maskstudio/issues
Author-email: Arthur <arthur@sart.dev>
License: MIT License
        
        Copyright (c) 2026 King Arthur
        
        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.
License-File: LICENSE
Keywords: annotation,computer-vision,desktop,image,labeling,mask,pyside6,qt,segmentation
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: MacOS X
Classifier: Environment :: Win32 (MS Windows)
Classifier: Environment :: X11 Applications :: Qt
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.12
Requires-Dist: numpy<3,>=2.2
Requires-Dist: opencv-python<5,>=4.10
Requires-Dist: pillow<13,>=11
Requires-Dist: pydantic<3,>=2.10
Requires-Dist: pyside6<7,>=6.8
Requires-Dist: shapely<3,>=2.0
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: ruff>=0.11; extra == 'dev'
Requires-Dist: twine>=6.1; extra == 'dev'
Description-Content-Type: text/markdown

# maskstudio

[![PyPI version](https://img.shields.io/pypi/v/maskstudio.svg)](https://pypi.org/project/maskstudio/)
[![Python versions](https://img.shields.io/pypi/pyversions/maskstudio.svg)](https://pypi.org/project/maskstudio/)
[![License](https://img.shields.io/pypi/l/maskstudio.svg)](https://github.com/reiarthur/maskstudio/blob/main/LICENSE)

MaskStudio is a vector-first desktop mask annotation studio for batch image
workflows. It opens a folder or a single image, keeps editable annotations as
Shapely geometry in image coordinates, and saves deterministic grayscale PNG
masks beside the source images.

## Supported operations

- Open a folder or single image (non-interactive path resolution)
- Paint, polygon, rectangle, and hole tools with edge-aware refinement
- Contour edit mode with vertex and edge handles
- Overview plus detail split view with adjustable ROI
- Undo/redo history per document
- Deterministic `<stem>_mask.png` output (mode `L`, black mask on white)

## Requirements

- Python 3.12 or newer
- Dependencies installed automatically by `pip`: `numpy`, `opencv-python`,
  `Pillow`, `pydantic`, `PySide6`, `shapely`
- On Linux, a working X11 or Wayland session is required for the Qt runtime

## Install

```bash
pip install maskstudio
```

## Checking the version

```python
import maskstudio

print(maskstudio.__version__)
```

## Configuration

MaskStudio does not require credentials or environment variables. Inputs are
passed either to the Python API or to the installed CLI launcher.

```python
import maskstudio

result = maskstudio.annotate_masks()
result = maskstudio.annotate_masks("/path/to/folder")
result = maskstudio.annotate_masks("/path/to/image.png")
```

```bash
maskstudio
maskstudio /path/to/folder
maskstudio /path/to/image.png
```

See [docs/configuration.md](docs/configuration.md) for the detailed input
resolution flow and supported raster formats.

## Quickstart

### Annotate every image in a folder

```python
import maskstudio

result = maskstudio.annotate_masks("/path/to/folder")
for saved_mask in result:
    print(saved_mask)
```

### Annotate a single image

```python
import maskstudio

result = maskstudio.annotate_masks("/path/to/image.png")
print(f"Saved {len(result)} mask(s)")
```

### Open the graphical folder picker

```python
import maskstudio

result = maskstudio.annotate_masks()
if not result.saved_paths:
    print("Session finished with no saved masks")
```

### Use the installed CLI launcher

```bash
maskstudio /path/to/folder
```

## Public API

| Module | Symbol | Description |
| --- | --- | --- |
| `maskstudio` | `annotate_masks(path=None)` | Launch the GUI and return an `AnnotationResult`. |
| `maskstudio` | `__version__` | Installed package version string. |
| `maskstudio.models` | `AnnotationRequest` | Frozen Pydantic request with optional `path`. |
| `maskstudio.models` | `AnnotationResult` | Frozen Pydantic result with `saved_paths`. |
| `maskstudio.exceptions` | `MaskStudioError` | Base class for every typed exception. |
| `maskstudio.exceptions` | `NoImagesFoundError` | Raised when a folder has no supported images. |
| `maskstudio.exceptions` | `UnsupportedImageError` | Raised when a file is not a supported image. |

## Supported input formats

The discovery layer accepts these raster formats case-insensitively:
`.png`, `.jpg`, `.jpeg`, `.bmp`, `.tif`, `.tiff`, `.webp`. Files whose name
already matches `*_mask.png` are skipped during folder scanning.

## Saved output rules

- Output path is always `<original_stem>_mask.png` in the source directory.
- Saved masks are always PNG, mode `L`.
- Background pixels are white (`255`); annotated pixels are black (`0`).
- Saved files never contain alpha, outlines, or display-only styling.

## Error handling

```python
import maskstudio
from maskstudio.exceptions import MaskStudioError, NoImagesFoundError

try:
    result = maskstudio.annotate_masks("/path/to/folder")
except NoImagesFoundError as error:
    print(f"No images in {error.path}")
except MaskStudioError as error:
    print(f"MaskStudio failed: {error}")
```

See [docs/errors.md](docs/errors.md) for the full exception hierarchy.

## Additional docs

- [docs/configuration.md](docs/configuration.md) — Input resolution, picker
  behavior, and supported formats.
- [docs/errors.md](docs/errors.md) — Exception hierarchy and recovery
  patterns.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup, test
commands, and the full build and publish workflow.
