ui-avatars
Deterministic avatar URLs for light and dark designs: Gravatar or Libravatar photos falling back to colored initials via ui-avatars.com. Same input, same URL, always.
Install
pip install ui-avatars
Usage
from ui_avatars import avatar_url
avatar_url(name="Ada Lovelace", email="ada@example.com")
# Gravatar photo, falling back to generated initials
avatar_url(name="Ada Lovelace")
# straight ui-avatars.com URL, no Gravatar lookup
avatar_url(email="ada@example.com")
# initials from the first two letters of the email
avatar_url(name="Ada Lovelace", alpha=0.75, size=256, rounded=True)
# alpha, size, and ui-avatars.com rendering options as one-off overrides
avatar_url(name="Ada Lovelace", color="#dc2626")
# pick a specific color, skipping the palette
avatar_url(name="Ada Lovelace", alpha=1, background="#000")
# pin the background, let the text color rotate with the palette
avatar_url(name="Ada Lovelace", font_color="#fff")
# pin the text color, let the background rotate with the palette
avatar_url(name="Ada Lovelace", email="ada@example.com", source="libravatar")
# look up the photo on Libravatar instead of Gravatar
avatar_url(name="Ada Lovelace", email="ada@example.com", source="avatars.example.com")
# or point at a self-hosted Gravatar-compatible server
avatar_url(name="Ada Lovelace", email="ada@example.com", format="png")
# force png or svg, note Gravatar errors for svg default images
Configuration
Reconfigure the shared avatars instance once, at startup, to change the palette for
every call:
from ui_avatars import avatars
avatars.configure(colors=["#1d4ed8", "#b91c1c"], size=256, rounded=True)
Or build your own instance instead:
from ui_avatars import Avatars
avatars = Avatars(colors=["#1d4ed8", "#b91c1c"], size=256)
avatars.build(name="Ada Lovelace", email="ada@example.com")
The default palette is tailwind_colors's
RAINBOW_500. You can swap the whole palette like so:
from tailwind_colors import TCH
avatars.configure(colors=TCH.RAINBOW_300)
For an independent background/text color instead of one tinted from the other, use a
(background, text) tuple as a colors entry — alpha still applies to whichever
background results:
avatars.configure(colors=[("#fee2e2", "#ef4444"), ("#ffedd5", "#f97316")])
Development
poetry install
poetry run pytest
poetry run ruff check .
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ui_avatars-1.2.1.tar.gz.
File metadata
- Download URL: ui_avatars-1.2.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15cac507de5eac76e24b8c23c27e105aa201aaf63999f69da34d3c05ca538732
|
|
| MD5 |
c529a2dfe5c69f5ba2e034c646f6af54
|
|
| BLAKE2b-256 |
587464d6fe5eda763efdac91ffe4b6ae9e600bc589f22c5d071656d4137b570e
|
Provenance
The following attestation bundles were made for ui_avatars-1.2.1.tar.gz:
Publisher:
release.yml on stevelacey/ui-avatars
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ui_avatars-1.2.1.tar.gz -
Subject digest:
15cac507de5eac76e24b8c23c27e105aa201aaf63999f69da34d3c05ca538732 - Sigstore transparency entry: 2618010601
- Sigstore integration time:
-
Permalink:
stevelacey/ui-avatars@3f6bb0d0ddb52b289e0953970dee4c24624fa12b -
Branch / Tag:
refs/tags/1.2.1 - Owner: https://github.com/stevelacey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3f6bb0d0ddb52b289e0953970dee4c24624fa12b -
Trigger Event:
push
-
Statement type:
File details
Details for the file ui_avatars-1.2.1-py3-none-any.whl.
File metadata
- Download URL: ui_avatars-1.2.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ff2523839c5713fad1f86ab737136667ee1abcca67429de47da27a90434b070
|
|
| MD5 |
93a7b9ca7420e6ac89b7f1b6654fd249
|
|
| BLAKE2b-256 |
b8cf3157bb95cae40168728bde060095c2b6202e88b8987077d67d59a5d7ed0a
|
Provenance
The following attestation bundles were made for ui_avatars-1.2.1-py3-none-any.whl:
Publisher:
release.yml on stevelacey/ui-avatars
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ui_avatars-1.2.1-py3-none-any.whl -
Subject digest:
8ff2523839c5713fad1f86ab737136667ee1abcca67429de47da27a90434b070 - Sigstore transparency entry: 2618010607
- Sigstore integration time:
-
Permalink:
stevelacey/ui-avatars@3f6bb0d0ddb52b289e0953970dee4c24624fa12b -
Branch / Tag:
refs/tags/1.2.1 - Owner: https://github.com/stevelacey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3f6bb0d0ddb52b289e0953970dee4c24624fa12b -
Trigger Event:
push
-
Statement type: