Oversimplified Github-like userpic (avatar) generator
Project description
Github-like Userpic (Avatar) Generator
Oversimplified Github-like userpic (avatar) generator.
Features
- Generate unique avatars from text input (email, username, etc.)
- Create both PIL Image and SVG outputs
- Customizable size, colors, and padding
- Deterministic output (same input always produces the same avatar)
Installation
pip install tiny-userpic
Usage
The library provides several ways to generate avatars:
1. Random Generation (Non-deterministic)
Generate a unique random avatar each time.
from tiny_userpic import make_userpic_image
# Generate random avatar
random_image = make_userpic_image(
size=(7, 5),
image_size=(300, 300),
background="white",
foreground="black"
)
random_image.save("random_avatar.png")
2. With Custom Seed (Deterministic)
Generate an avatar with a specific seed for reproducible results.
from tiny_userpic import make_userpic_image
# Generate avatar with specific seed
seeded_image = make_userpic_image(
size=(7, 5),
image_size=(300, 300),
background="white",
foreground="black",
seed=42 # Any integer value will work as seed
)
seeded_image.save("seeded_avatar.png")
3. From Text Input (Deterministic)
Generate an avatar from any text input (email, username, etc.). The same input will always produce the same avatar.
from tiny_userpic import make_userpic_image_from_string, make_userpic_svg_from_string
# Generate avatar from email
email = "user@example.com"
# As PNG image
image = make_userpic_image_from_string(
text=email, # Input text to generate avatar from
size=(7, 5), # Pattern size (width, height)
image_size=(300, 300), # Output image size in pixels
background="white", # Background color (can be color name, hex or RGB tuple)
foreground="black" # Foreground color (can be color name, hex or RGB tuple)
)
image.save("avatar.png")
# As SVG
svg = make_userpic_svg_from_string(
text=email,
size=(7, 5),
image_size=(300, 300),
background="white",
foreground="black"
)
with open("avatar.svg", "w") as f:
f.write(svg)
Common Parameters
All generation methods share these parameters:
size: Tuple of (width, height) for the pattern sizeimage_size: Tuple of (width, height) for the output image size in pixelsbackground: Background color (can be color name, hex or RGB tuple)foreground: Foreground color (can be color name, hex or RGB tuple)padding: Optional padding around the pattern (default: (20, 20))mode: Image mode for PNG output (default: 'RGB', can be 'RGBA' for transparency)
Examples
Basic (from string)
Colored
Transparent
Small
Large
Random (non-deterministic)
Seeded (deterministic)
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
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 tiny_userpic-0.4.0.tar.gz.
File metadata
- Download URL: tiny_userpic-0.4.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b22d9088b041b2a5dfef2fe80dd787ac6b9a880a78d7190925f48e8d215875b
|
|
| MD5 |
9e808e1882f63db1d578992100ce95ad
|
|
| BLAKE2b-256 |
326afe046151baeef3b1d7da38342fda2a5b4fe986cbc92eda7a6e54c68cd281
|
File details
Details for the file tiny_userpic-0.4.0-py3-none-any.whl.
File metadata
- Download URL: tiny_userpic-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2eea87efd85f23ef62ba2a621ee8a727dc9d3e6162ff16e39ac1cef170020a58
|
|
| MD5 |
6a8d5db1e0d8c49eff1c479ca0e7bb66
|
|
| BLAKE2b-256 |
671d5fcc5608b934622e9ed0e40b1ab04594a966d0215d39e7e9ac08ff3891b1
|