Avatar
Base class for the avatar generator.
class DAvatar
Properties
style
(DStyle): the style of the avatarseed
(str): the seed of the avataroptions
(DOptions): the options of the avatarcustomisations
(dict): the customisations of the avatar (alias:customs
)url_svg
(str): svg url for the avatarurl_webp
(str): webp url for the avatarurl_avif
(str): avif url for the avatarurl_png
(str): png url for the avatarurl_jpg
(str): jpg url for the avatarurl_jpeg
(str): jpeg url for the avatarurl_json
(str): json url for the avatar dataschema
(dict): the dict schema of the avatar style
def __init__()
Create an avatar using this class. str(DAvatar)
returns the svg url.
Returns:
None
: when called as string it will return the svg link
Parameter | Type | Default | Description |
---|---|---|---|
|
| ||
|
| Base string to determine the avatar. | |
|
| General options for the avatar. | |
|
| Customisations (for the chosen style) |
def edit()
Edit an already existing DAvatar
.
Returns:
str
: the svg link of the edited avatar
Parameter | Type | Default | Description |
---|---|---|---|
|
| ||
|
| Base string to determine the edited avatar. | |
|
| Edit the avatar's options (old options stay, these get added or overwrite if they already existed). | |
|
| Edit the avatar's options (all old options get deleted and these get added, replacing the old options). |
def edit_specific()
Deprecated: removed since v2.2.3
-> use DAvatar.customise()
instead.
def customise()
Alias: customize()
Customise the specific options for an already existing avatar. Specific options/customisations are different for every style, so make sure to check all the possibilities here.
Returns:
str
: the svg link of the edited avatar
Parameter | Type | Default | Description |
---|---|---|---|
|
| Edit the avatar's options (old options stay, these get added or overwrite if they already existed). | |
|
| Edit the avatar's options (all old options get deleted and these get added, replacing the old options). |
def save()
Save the avatar to your device.
Returns:
str
: the path where the avatar has been saved if successful else-1
Raises:
ImageValueError
: Image has a ValueError
ImageOSError
: Image cannot be written to your devide (OSError)
Exception
: Unknown Exception
Parameter | Type | Default | Description |
---|---|---|---|
| current directory | Location to save the avatar file. | |
|
| Name to give the avatar file. | |
| DFormat.svg | Which format to use. | |
|
| Whether to overwrite already existing images with the given filename. | |
|
| Whether to open the image after saving. |
def view()
Alias: open()
Open and view a DAvatar
object.
Returns:
None
Parameter | Type | Default | Description |
---|---|---|---|
|
| What format to use when opening the avatar image. | |
|
| Whether to use PIL module or something else to open the avatar. |
def pillow()
Convert a DAvatar
instance to a PIL.Image.Image
object.
Returns:
PIL.Image.Image
: the Image object to edit using the Pillow moduleRaises:
PILError
: if Pillow module is not found on your device
def text()
Returns the avatar's full text/file in str
format. (only useful for svg
and json
)
Returns:
str
: the text of the image
Parameter | Type | Default | Description |
---|---|---|---|
|
| What format to use. |
def bytes()
Returns the avatar's bytes in io.BytesIO
format (only useful for png
and jpg
).
Use io.BytesIO.read()
to convert it to actual bytes when necessary.
Returns:
io.BytesIO
: the bytes of the image
Parameter | Type | Default | Description |
---|---|---|---|
|
| What format to use. |
Last updated