Skip to main content

Unique avatars from dozens of styles — deterministic, customizable, vector-based.

Project description

DiceBear Core (Python)

Deterministic, customizable, vector-based avatars — the Python port of the DiceBear core engine. It produces byte-identical SVG output to the reference JavaScript implementation (@dicebear/core) for the same style definition and options.

This package contains only the rendering engine. Avatar style definitions ship separately as language-agnostic JSON via dicebear-styles (or any other source of a DiceBear style definition).

Installation

pip install dicebear-core

Requires Python 3.10 or newer.

Usage

import json
from importlib.resources import files

from dicebear import Avatar

# Load a style definition (here from the dicebear-styles package).
style = json.loads(
    files("dicebear_styles").joinpath("adventurer.json").read_text("utf-8")
)

avatar = Avatar(style, {"seed": "John"})

avatar.to_string()    # the SVG markup
avatar.to_data_uri()  # data:image/svg+xml;charset=utf-8,...
avatar.to_json()      # {"svg": ..., "options": {...resolved options...}}

Avatar accepts either a raw style-definition dict or a Style instance, plus an optional options dict:

from dicebear import Avatar, Style

style = Style(style_data)
Avatar(style, {"seed": "John", "size": 128, "backgroundColor": ["b6e3f4"]})

Development

This package lives in the DiceBear monorepo under src/python/core. See CONTRIBUTING.md in the repository root for the full workflow.

cd src/python/core
pip install -e ".[dev]"
ruff check .
mypy src
pytest

The decisive check is tests/test_parity.py, which asserts byte-identical output against the shared fixtures in tests/fixtures/parity/ (generated from the JavaScript reference).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dicebear_core-10.2.0rc1.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dicebear_core-10.2.0rc1-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file dicebear_core-10.2.0rc1.tar.gz.

File metadata

  • Download URL: dicebear_core-10.2.0rc1.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dicebear_core-10.2.0rc1.tar.gz
Algorithm Hash digest
SHA256 13e7d0623ce797e992274df116c0fac0af7b00770df1132e06a3be6dd04ebd62
MD5 caca3b629182f1d10e1c3524ae0ae972
BLAKE2b-256 046c88617cb264a6bd282e86c0424d43437f73a7e031a8f3181b745577290ed7

See more details on using hashes here.

Provenance

The following attestation bundles were made for dicebear_core-10.2.0rc1.tar.gz:

Publisher: publish.yml on dicebear/dicebear

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dicebear_core-10.2.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for dicebear_core-10.2.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 de6ca7a55894b17e965621a001d5680402fac7677707191623d0a22ca6feba9c
MD5 05e4a7fb727dc555303662e76b1a934f
BLAKE2b-256 b26d1c9809d090be7c3174edd5251854b3767816e4da0e1547610a5009faa515

See more details on using hashes here.

Provenance

The following attestation bundles were made for dicebear_core-10.2.0rc1-py3-none-any.whl:

Publisher: publish.yml on dicebear/dicebear

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page