Metadata-Version: 2.5
Name: captionm
Version: 0.1.0
Summary: Customizable media captioning engine for images, GIFs, and videos with discord.py support.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: av>=12.0.0
Requires-Dist: pillow>=10.0.0
Provides-Extra: heif
Requires-Dist: pillow-heif>=0.16.0; extra == 'heif'
Description-Content-Type: text/markdown

# captionm

simple python library for adding, removing, and replacing captions on images, gifs, and videos. works anywhere (web backends, scripts, discord bots, whatever).

## install

```bash
pip install captionm
```

needs python 3.10+. uses pillow and pyav under the hood.

## basic usage

```python
from captionm import caption_bytes, uncaption_bytes, recaption_bytes, CaptionStyle

with open("meme.gif", "rb") as f:
    raw = f.read()

# add caption
buf, ext = caption_bytes(raw, "ohfr?")

# remove caption bar
buf, ext = uncaption_bytes(raw)

# replace caption
buf, ext = recaption_bytes(raw, "new text")

with open(f"out.{ext}", "wb") as f:
    f.write(buf.read())
```

## styling

pass `CaptionStyle` if you don't want the default white top bar:

```python
style = CaptionStyle(
    font="path/to/font.otf",
    text_color="white",
    bg_color="black",
    uppercase=True,
)

buf, ext = caption_bytes(raw, "hello", method="bottom_bar", style=style)
```

available methods: `top_bar`, `bottom_bar`, `overlay_top`, `overlay_bottom`, `overlay_center`, `area`.

## notes

- renders unicode emojis and custom discord emojis in color by default (`render_emojis=False` to turn off).
- if you have `discord.py` installed, `caption_message`, `uncaption_message`, and `recaption_message` are also exported.
- use `EngineLimits` if you need to cap resolution, frames, file size, or timeout.