Skip to main content

scrybe-mermaid

Standalone PNG iTXt codec: embeds and extracts Mermaid diagram source as invisible metadata inside a PNG file. Python on the outside, Rust on the inside.

What it does

Uses the PNG iTXt (international text) metadata chunk mechanism to store Mermaid diagram source alongside the rendered image. The PNG is fully valid and renders normally in any image viewer. The source text travels with the image and can be round-tripped without loss.

Python quick start

pip install scrybe-mermaid
from pathlib import Path
from scrybe_mermaid import embed, extract

source = """
graph TD
    A[Christmas] -->|Get money| B(Go shopping)
    B --> C{Let me think}
    C -->|One| D[Laptop]
    C -->|Two| E[iPhone]
"""

# diagram.png: any PNG — render one with mmdc, Kroki, or the Mermaid live editor
png_in = Path("diagram.png").read_bytes()
png_out = embed(png_in, source)
Path("diagram-with-source.png").write_bytes(png_out)

payload = extract(png_out)  # verifies the embedded sha256 — raises ValueError if tampered
if payload.source != source:  # optional
    raise ValueError("Round-trip mismatch")
print(f"Round-tripped {len(payload.source)} chars; sha256={payload.sha256[:12]}…")

The resulting PNG renders normally in any image viewer and carries its own Mermaid source for round-tripping. See the API reference below.

Codec format

  • Chunk key: scrybe-mermaid
  • Value: JSON { "source": "<mermaid source>", "sha256": "<hex>", "uuid": "<v4>" }

The sha256 field is a SHA-256 digest of the source bytes, and extract enforces it by default: the digest is recomputed from the extracted source and compared against the stored value. Three outcomes are distinguished:

Outcome Python Rust
Digest present and matching payload with verified == True Ok(VerifiedPayload) with VerificationStatus::Verified
Digest present but mismatched (tampered) raises ValueError Err(MermaidError::VerificationFailed { expected, actual, .. })
No digest stored (older/foreign payload) payload with verified == False, sha256 == "" Ok(VerifiedPayload) with VerificationStatus::NoDigest

A payload with no digest is never reported as verified. For forensics on tampered or foreign payloads, extract_unverified returns the raw stored fields without any check.

Role in the architecture

scrybe-mermaid is a self-contained utility crate with no dependency on scrybe-core. It is used by scrybe-mcp-server (the embed/extract tools), scrybe-cli (scrybe mermaid embed/extract/verify), and the Tauri backend.

Key public types and entry points

Symbol Description
embed(png_bytes, source) -> Result<Vec<u8>> Inserts iTXt chunk; returns modified PNG bytes
extract(png_bytes) -> Result<VerifiedPayload> Reads the iTXt chunk and verifies the stored sha256 against the source; mismatch → MermaidError::VerificationFailed
extract_unverified(png_bytes) -> Result<MermaidPayload> Raw stored fields, no digest check (forensics)
VerifiedPayload source: String + uuid: String + verification: VerificationStatus
VerificationStatus Verified { algorithm, digest } or NoDigest (older/foreign payloads)
MermaidPayload Raw stored source + sha256 + uuid (unchecked)
MermaidError Error type covering missing chunk, malformed JSON, PNG decode failure, digest mismatch (VerificationFailed { expected, actual, .. })

Build and test

cargo build -p scrybe-mermaid
cargo test -p scrybe-mermaid

The codec parses PNG chunks from first principles — no external binaries required.

Metadata

Release files for scrybe-mermaid 0.7.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 scrybe-mermaid 0.7.0
File Size Uploaded Provenance Actions
scrybe_mermaid-0.7.0.tar.gz 56.6 kB With provenance Details for scrybe_mermaid-0.7.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for scrybe-mermaid 0.7.0
File Interpreter ABI Platform Actions
scrybe_mermaid-0.7.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for scrybe_mermaid-0.7.0-cp39-abi3-win_amd64.whl
scrybe_mermaid-0.7.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for scrybe_mermaid-0.7.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
scrybe_mermaid-0.7.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for scrybe_mermaid-0.7.0-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 914.4 kB

Release files / scrybe_mermaid-0.7.0.tar.gz

Download URL scrybe_mermaid-0.7.0.tar.gz
Size 56.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f2ed4c93f47f6e11daef68194009b213a22681926a06dd19103e077445e4cadf
BLAKE2b-256 checksum
How to use checksums
050efb5c452b76b9a5800b430b6063e308fddd522019a4198ac052d3b1776650
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 11, 2026.

Transparency log

Release files / scrybe_mermaid-0.7.0-cp39-abi3-win_amd64.whl

Download URL scrybe_mermaid-0.7.0-cp39-abi3-win_amd64.whl
Size 200.2 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0475b061df1b3d6f59f59be6baa6ec80e9dbc8742bb4ef5a99065c8cf007e0fe
BLAKE2b-256 checksum
How to use checksums
a6dd63f13d7bbc2fe84a6fe2901d3db57ad576f692362b820a774e1729b34b5e
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 11, 2026.

Transparency log

Release files / scrybe_mermaid-0.7.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL scrybe_mermaid-0.7.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 349.3 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
3542a6650e4ae4767e869c2e62126fc6baecac122fd0808661cc5b66afb6829a
BLAKE2b-256 checksum
How to use checksums
5b1bd728698378d37f8b4dde50f67d47bd63b22175ba59ab53d8061f0f20fb19
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 11, 2026.

Transparency log

Release files / scrybe_mermaid-0.7.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL scrybe_mermaid-0.7.0-cp39-abi3-macosx_11_0_arm64.whl
Size 308.3 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6d42a8596bf666905d88f7ccf13f0dcb53b607bcedc69bec8f8a1babee7fc242
BLAKE2b-256 checksum
How to use checksums
81f558f2adabc41305bb4c589583a04df2526b76933662dadacd2d96156b8551
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 11, 2026.

Transparency log

Security for scrybe-mermaid 0.7.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

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for scrybe_mermaid-0.7.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 11, 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.

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