
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Avatar library in Python
Using pip, from PyPi (latest stable release):
pip install python-avatars
Using pip, from this repository (May not be stable!):
git clone https://github.com/ibonn/python_avatars.git python_avatars
cd python_avatars
pip install -e .
import python_avatars as pa
my_avatar = pa.Avatar(
style=pa.AvatarStyle.CIRCLE,
background_color=pa.BackgroundColor.BLACK,
top=pa.HairType.STRAIGHT_2,
eyebrows=pa.EyebrowType.DEFAULT_NATURAL,
eyes=pa.EyeType.DEFAULT,
nose=pa.NoseType.DEFAULT,
mouth=pa.MouthType.EATING,
facial_hair=pa.FacialHairType.NONE,
# You can use hex colors on any color attribute...
skin_color="#00FFFF",
# Or you can use the colors provided by the library
hair_color=pa.HairColor.BLACK,
accessory=pa.AccessoryType.NONE,
clothing=pa.ClothingType.HOODIE,
clothing_color=pa.ClothingColor.HEATHER
)
# Save to a file
my_avatar.render("my_avatar.svg")
import python_avatars as pa
# Completely random avatar
random_avatar_1 = pa.Avatar.random()
# Completely random avatar except for the hat
random_avatar_2 = pa.Avatar.random(top=pa.HatType.HAT) # More attributes can stay fixed
# Fixed avatar but random clothes
random_avatar_3 = pa.Avatar(
style=pa.AvatarStyle.CIRCLE,
hair_color=pa.HairColor.BLACK,
accessory=pa.AccessoryType.NONE,
clothing=pa.ClothingType.pick_random(), # The clothes are chosen randomly
)
When using the graphic shirt, - ClothingType.GRAPHIC - you can set a custom text if you want to.
import python_avatars as pa
pa.Avatar(
style=pa.AvatarStyle.CIRCLE,
background_color='#FF00FF',
# Choose graphic shirt
clothing=pa.ClothingType.GRAPHIC_SHIRT,
clothing_color=pa.ClothingColor.GRAY_02,
# Important to choose this as shirt_graphic, otherwise shirt_text will be ignored
shirt_graphic=pa.ClothingGraphic.CUSTOM_TEXT,
shirt_text='Chess'
).render("avatar_text.svg")
will output the file avatar_text.svg:
Suppose you have a file called suit.svg that looks like this
You can add it to the library just by running
from python_avatars import install_part
# Install the new part
install_part("suit.svg", pa.ClothingType)
And then use it
suit_avatar = pa.Avatar.random(
clothing=pa.ClothingType.SUIT
)
suit_avatar.render("suit_avatar.svg")
Which outputs the file suit_avatar.svg that looks like this
The name of the newly added value will be exactly the name of the svg file converted to uppercase replacing all non alphanumeric chars with underscores and removing all leading digits.
Uninstalling the installed part is as easy as installing it
from python_avatars import uninstall_part, ClothingType
uninstall_part(ClothingType.SUIT, confirm=False) # confirm=False will not prompt for confirmation
This project is licensed under the MIT License - see the LICENSE file for details
FAQs
SVG avatar library for Python
We found that python-avatars demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.