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.0rc1.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.0rc1-py3-none-any.whl (34.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dicebear_core-10.1.0rc1.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.0rc1.tar.gz
Algorithm Hash digest
SHA256 e80d12dd6c7904f684631948b856f730a65ec5541f4d388ae58bc8696b824cb5
MD5 dc8afe827579a9cc304f000225896918
BLAKE2b-256 3aef0269576f339b5f5f42d3d20f0e05f2ea47368b32e47df3e0c9ede75c6c71

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dicebear_core-10.1.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 1609359fbd23b14285ccd17f639b255343c4fce1081c3d7ecde5a8776c98580a
MD5 bdda4a76cbaef3438db6ece1ab9677fc
BLAKE2b-256 f524affe30b5045a903c031c810c87071cd25f0b5a9b1e4d966059dcb40920bd

See more details on using hashes here.

Provenance

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