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 JavaScript (@dicebear/core) and PHP (dicebear/core) implementations 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.1.0.tar.gz (39.2 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.1.0-py3-none-any.whl (34.5 kB view details)

Uploaded Python 3

File details

Details for the file dicebear_core-10.1.0.tar.gz.

File metadata

  • Download URL: dicebear_core-10.1.0.tar.gz
  • Upload date:
  • Size: 39.2 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.1.0.tar.gz
Algorithm Hash digest
SHA256 63615835ee07f5b072cbc8b74dadda64625a9aa6a8d2857f1baa11ebe516bdab
MD5 3600f592bed7d8fdc40fba1a53762d22
BLAKE2b-256 b07c2a3699b3bd54a5adf702b402d7fe3aef459c3abf32d4b7c274c3c4a0e221

See more details on using hashes here.

Provenance

The following attestation bundles were made for dicebear_core-10.1.0.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: dicebear_core-10.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dicebear_core-10.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2304a135dcb2f68bf23b63c4e67072797c0c97da2022be68111ad7d33cb93fc
MD5 5bfc2617d37d0bf2ab4da7929c5a6812
BLAKE2b-256 2f2a57b1b9df189d5f62f359b07b5e8f6aaf754bf2e50a6adf4b627c86f6b207

See more details on using hashes here.

Provenance

The following attestation bundles were made for dicebear_core-10.1.0-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