Avatar using Python | Creating an Avatar using Python Programming Language.
Creating an Avatar using Python Programming Language.
In this article you will get to know how to create an avatar using python programming language.
Before that you need to know What is Python Programming Language, What is an Avatar.
What is Python?
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.
What is an avatar?
An avatar is a graphical representation of a user or the user’s character. It may take either a two dimensional form as an icon in Internet forums and other social media where it is also known as profile picture or a three dimensional form as in games or virtual worlds.
How to create an avatar using python?
For this firstly you need to have Python software installed in your system. And you also need to install an Avatar module. To install the module. Type this in your command prompt
“pip install py-avataaars”
Or check the command in official website Click Here or https://pypi.org/project/py-avataaars/
Also you need to install a GTKapplication. From GitHub Click Here to download it or https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer after going to this link you need to see the .exe file and download it. Kindly scroll down to see .exe file.
During installing this application your anti virus defender may prevent the installation but try to install it.
After the module is installed either you can use the default IDLE or you can use code editors if you are familiar with them. Code editors such as VS Code, PyCharm etc.
Write down the code:
# importing the require package
from py_avataaars import PyAvataaar
# assigning various parameters to our avatar
avatar = PyAvataaar()
# rendering the avatar in png format
avatar.render_png_file("Default_Avatar_1.png")
This is how default avatar looks.
The above code is to get the default avatar to implement different styles in it and write the below code.
Also check below the code to make even more changes for the avatar.
#Other styles
import py_avataaars as pa
avatar = pa.PyAvataaar(
style=pa.AvatarStyle.CIRCLE,
skin_color=pa.SkinColor.LIGHT,
hair_color=pa.HairColor.BROWN,
facial_hair_type=pa.FacialHairType.DEFAULT,
facial_hair_color=pa.HairColor.BLACK,
top_type=pa.TopType.SHORT_HAIR_SHORT_FLAT,
hat_color=pa.Color.BLACK,
mouth_type=pa.MouthType.SMILE,
eye_type=pa.EyesType.DEFAULT,
eyebrow_type=pa.EyebrowType.DEFAULT,
nose_type=pa.NoseType.DEFAULT,
accessories_type=pa.AccessoriesType.DEFAULT,
clothe_type=pa.ClotheType.GRAPHIC_SHIRT,
clothe_color=pa.Color.HEATHER,
clothe_graphic_type=pa.ClotheGraphicType.BAT,)
avatar.render_png_file('output_file_name.png')
Check out this to make even more changes for the avatar.
Style #SQUARE, CIRCLE
Skin_color #BLACK, BROWN, DARK_BROWN, LIGHT, PALE, TANNED, YELLOW
Hair_color #AUBURN, BLACK, BLONDE, BLONDE_GOLDEN, BROWN, BROWN_DARK, PASTEL_PINK, PLATINUM, RED, SILVER_GRAY.
Facial_hair_type #DEFAULT
Facial_hair_color #BEARD_LIGHT, BEARD_MAJESTIC, BEARD_MEDIUM, FACIAL_HAIR_COLOR, MOUSTACHE_FANCY, MOUSTACHE_MAGNUM
Top_type #EYE_PATCH, HAIR_COLOR, HAT, HAT_COLOR, HIJAB, LONG_HAIR_BIG_HAIR, LONG_HAIR_BOB, LONG_HAIR_BUN, LONG_HAIR_CURLY, LONG_HAIR_CURVY, LONG_HAIR_DREADS, LONG_HAIR_FRIDA, LONG_HAIR_FRO, LONG_HAIR_FRO_BAND, LONG_HAIR_MIA_WALLACE, LONG_HAIR_NOT_TOO_LONG, LONG_HAIR_SHAVED_SIDES, LONG_HAIR_STRAIGHT, LONG_HAIR_STRAIGHT2, LONG_HAIR_STRAIGHT_STRAND, NO_HAIR, SHORT_HAIR_DREADS_01, SHORT_HAIR_DREADS_02, SHORT_HAIR_FRIZZLE, SHORT_HAIR_SHAGGY_MULLET, SHORT_HAIR_SHORT_CURLY, SHORT_HAIR_SHORT_FLAT, SHORT_HAIR_SHORT_ROUND, SHORT_HAIR_SHORT_WAVED, SHORT_HAIR_SIDES, SHORT_HAIR_THE_CAESAR, SHORT_HAIR_THE_CAESAR_SIDE_PART, TURBAN, WINTER_HAT1, WINTER_HAT2, WINTER_HAT3, WINTER_HAT4
Hat_color # BLACK, BLUE_01, BLUE_02, BLUE_03, GRAY_01, GRAY_02, HEATHER, PASTEL_BLUW, PASTEL_GREEN, PASTEL_ORANGE, PASTEL_RED, PASTEL_YELLOW, PINK, RED, WHITE
Mouth_type #CONCERNED, DEFAULT, DISBELIEF, EATING, GRIMACE, SAD, SCREAM_OPEN, SERIOUS, SMILE, TONGUE, TWINKLE, VOMIT
Eye_type #CLOSE, CRY, DEFAULT, DIZZY, EYE_ROLL, HAPPY, HEARTS, SIDE, SQUINT, SURPRISED, WINK WINK_WACKY
Eyebrow_type #ANGRY, ANGRY_NATURAL, DEFAULT, DEFAULT_NATURAL, FLAT_NATURAL, FROWN_NATURAL, RAISED_EXCITED, RAISED_EXCITED_NATURAL, SAD_CONCERNED, SAD_CONCERNED_NATURAL, UNI_BROW_NATURAL, UP_DOWN, UP_DOWN_NATURAL.
Nose_type #DEFAULT
Accessories_type #KURT, PRESCRIPTION_01, PRESCRIPTION_02, ROUND, SUNGLASSES, WAYFARERS.
Clothe_type #BLAZER_SHIRT, BLAZER_SWEATER, CLOTHE_COLOR, COLLAR_SWEATER, GRAPHIC_SHIRT, HOODIE, OVERALL, SHIRT_CREW_NECK, SHIRT_SCOOP_NECK, SHIRT_V_NECK
Clothe_color #HEATHER
Clothe_graphic_type #BAT, BEAR, CUMBIA, DEER, DIAMOND, HOLA, PIZZA, RESIST, SELENA, SKULL, SKULL_OUTLINE
The first college image were there are 6 avatars are there it is done by changing the default design.
This is how you create different kinds of avatar using python.
Comment if you want any help regarding this.
Also Check my other blogs on different articles as well.
There is also a website that which is very useful for mechanical engineering students and professionals as well. Click Here
Comments
Post a Comment