Package: dicebear
DiceBear Py WrapperAlways keep an eye onhttps://dicebear.janvh.tkfor updates and warnings about this packages!dicebearis an API wrapper forhttps://dicebear.com. Using this wrapper you can get custom avatars for your program.For an example go toexamples/dicebear.py.Useful linksDocs:https://jvherck.github.io/dicebearPyPI:https://pypi.org/project/dicebear/GitHub:https://github.com/jvherck/dicebearDicebear:https://dicebear.com/Dicebear CLI:https://github.com/jvherck/dicebear-cliChangelogFind the changelog here:https://github.com/jvherck/dicebear/blob/main/CHANGELOG.mdHow to installRunpip install dicebearIf that doesn't work trypy -m pip install dicebearUsageImportant note:Pillowis not a required dependency, it's only required when you want to be able to edit the avatar images (usingDAvatar.pillow()).
When using aPILfunction while it's not installed it will raisedicebear.errors.PILError.importPIL.ImagefromdicebearimportDAvatar,DStyle,DOptions,DColor,DFormat,bulk_create# Creating optionsoptions=DOptions(backgroundColor=DColor("00ddd0"),rotate=90)# Making a DAvatar objectav=DAvatar(style=DStyle.pixel_art,seed="John Apple",options=options)print(av.url_svg)# Prints the svg url# Editing the DAvatar objectav.edit(extra_options=DOptions(backgroundColor=DColor("000000")))# Using `extra_options` keep the `rotate` option but override the `backgroundColor` optionprint(av.url_png)# Prints the png url# Editing the style specific customisationsav.customise(blank_options={"face":"variant04"})# Using `blank_options` will delete your previous customisations for this DAvatar and generate new onesprint(av.url_jpg)# Prints the jpg url# Saving an avatar to your deviceav.save(location=None,# Passing `None` will save it in the current working directoryfile_name="dicebear_avatar",file_format=DFormat.svg,overwrite=True,open_after_save=False)# Converting the DAvatar object into a PIL.Image.Image objectav_img:PIL.Image.Image=av.pillow()# Opening and viewing the DAvatar imageav.open(use_pil=True)# or av.view()# Creating multiple random avatars of the same style at onceavatars:list=bulk_create(style=DStyle.random(),amount=10)CLI UsageDicebear has a CLI package that uses Python to generate avatars quickly.
You can't customize each avatar, to do that you'll need to use the Python module.To use the CLI runpip install dicebear-cliin a terminal.
Documentation can be found here:https://github.com/jvherck/dicebear-cli.CustomizationCustomize your avatars with these possibilities.StylesAll the possible avatar styles.https://dicebear.com/stylesadventureradventurer-neutralavataaarsavataaars-neutralbig-earsbig-ears-neutralbig-smilebotttsbottts-neutralcroodlescroodles-neutralfun-emojiiconsidenticoninitialsloreleilorelei-neutralmicahminiavsnotionistsnotionists-neutralopen-peepspersonaspixel-artpixel-art-neutralringsshapesthumbsBase OptionsAll the possible options for the avatar. These options work for all the styles.seed(type:str) - the seed for the avatar generator, determine its basic looksflip(type:bool) - flips the image vertically (default False)rotate(type:int) - rotates the avatar (default 0, min 0, max 360)scale(type:int) - the scale of the avatar drawing itself (default 100, min 0, max 200)radius(type:int) - the radius of the avatar (default 0, min 0, max 50)size(type:int) - the size of the avatar (px) (default 256, min 1, max 256)backgroundColor(type:DColor("transparent")) - the background color of the avatar. this can be a list of strings
if you havebackgroundTypeset to "gradientLinear". (default transparent)backgroundType(type:str) - set the background to eithergradientLinearorsolid(default solid)backgroundRotation(type:int) - rotate the background if backgroundType is set togradientLinear(default 0)translateX(type:int) - move the avatar horizontally (default 0, min -100, max 100)translateY(type:int) - move the avatar vertically (default 0, min -100, max 100)randomizeIds(type:bool) - randomize the IDs in the generated SVG/XML, can be useful if the avatars are included
directly in HTML and you want to avoid ID conflicts (default false)Specific Style OptionsSpecific options to get a more detailed avatar. This is different for every style.Click the style to see its options.adventureradventurer-neutralavataaarsavataaars-neutralbig-earsbig-ears-neutralbig-smilebotttsbottts-neutralcroodlescroodles-neutralfun-emojiiconsidenticoninitialsloreleilorelei-neutralmicahminiavsnotionistsnotionists-neutralopen-peepspersonaspixel-artpixel-art-neutralringsshapesthumbsFormatsThese are the only supported formats.If you have Pillow (PIL) installed you can convertDAvatarto aPIL.Image.Imageobject to get a
wider range of formats (Pillow doesn't support svg).DFormat.svg(default)DFormat.pngDFormat.jpgDFormat.jsonCreditsSpecial thanks toDiceBear(Florian Körner) for
making this amazing API and toall artiststhat helped making avatars!Licenses and privacy policyDicebearLicenses:https://dicebear.com/licensesDicebearPrivacy Policy:https://dicebear.com/legal/privacy-policyDicebear Python API wrapper (this project):https://dicebear.janvh.tk/license