Skip to main content

captionm

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

install

pip install captionm

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

basic usage

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:

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.

Metadata

Release files for captionm 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for captionm 0.1.0
File Size Uploaded Provenance Actions
captionm-0.1.0.tar.gz 12.9 kB With provenance Details for captionm-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for captionm 0.1.0
File Interpreter ABI Platform Actions
captionm-0.1.0-py3-none-any.whl Python 3 none any Details for captionm-0.1.0-py3-none-any.whl

Total release size: 26.1 kB

Release files / captionm-0.1.0.tar.gz

Download URL captionm-0.1.0.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
318e63dfed4dcc0dbd110ddfce92fd0b3f5dea14f20d12cd72182de681bfc8d6
BLAKE2b-256 checksum
How to use checksums
772a536866b5987092aeaa5e02c9bca7770c8d18997361d3b2097a986edfa98e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / captionm-0.1.0-py3-none-any.whl

Download URL captionm-0.1.0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd2ba3abd1b36ef2de81c1fd7823d7cd679d920f45738ec1b526819d932ca340
BLAKE2b-256 checksum
How to use checksums
daa9c0339cf414dd01b9516e2d07c223309bcc56b81ae8c2666061abb558f88d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for captionm 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for captionm-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page