 So I just learned about this open-source project online for generating random avatars that you can use in your software So let's go ahead. I'm just going to show you how it works how their API works Something you can install yourself, but you can also just use their API to generate some random avatars. Let's get started This is the website avatars.dyspair.com. In fact right now if you just go to dyspair.com It forwards you to the sub domain of avatars.dyspair.com right here You can see an example of one of the avatars It's set to male and if you give it a custom seed you'll see that it changes randomly depending on what we're typing in there You can change it to female and get a female character. You can do human which will give you male or female You don't know and then there's other options too. I also like their bots one, which will give you like a little bot avatar It is a open-source project. Here's their github page Dyspair and if you look at the license, it's an MIT license So let's go back here again. This is something that you can install to generate something on your own system But they also have a very basic HTTP API, which makes it super simple So if you need to generate a random avatar for a game or an application you can do that here It also generates you can have it create just little avatars with initials in there So if you know your users initials you can have it generate something that way But let's go ahead and just have a look at how this works. It's super simple. So here we go Here's an example. This is their API so you go just go to this URL that's the word I'm looking for and then here you're gonna replace where it says colon sprites with one of their options male female sprites Identicon initials bots so forth so on and then here you're gonna put in a random seed And it's going to give you an SVG as an output. Let me go ahead and copy their example here Which also gives a value for a background if you don't give it a background value It's going to give you a pn or sorry an SVG with a transparent background But here where you were using hex code zero zero zero ff that's going to be blue So let's go ahead and copy that open up a new tab paste that in there hit enter There is our average our avatar so you can see here It's male and this is we wrote John here But that's just your your random seed so I can type anything there and it will give us a new male character Based on what we type in there and every time you use that seed it's going to give you the same results So you would want to generate something random each time if you want a random Output again the background is hex code. So right now it's set to blue I can set it if I do ff that's going to be all red and all blue So we're gonna get a pink color or Muav if you will And here's a here's an example or a little test for you If I do all red all green and no blue what color you get what does red and green get? yellow yellow, okay Watch my video about this is a yellow truck for more on colors like that So again if we just leave out the backgrounds, we're gonna get an SVG with a transparent background Again, I can change this to from male to female and I'm going to get the female version of that character I can type in something random again here That's a funny looking one. Let's try another one. There we go So we have a female character again I can come in here and I can change this from female to male and there's the male version of that character and We can also another option here would be Bots with three Ts and an S should give us a bot Random characters gives us that and again if you want randomly male or female You just type in human and it will give you a human character Let's look at their API gives you a little more information here You can also do things like setting the mood you can make them happy or sad So let's go ahead and grab that John character again paste him in there this time with mood equals happy Look, he's smiling, but if I change happy to sad same character, but now he's frowning So there's some examples and of course I can go ahead and take one of these copy it and In this empty folder here. I can you wget or curl and I'm just going to type in that URL And it downloaded a file if I list out you can see it there if I file it out You can see that it is a vector graphic image and if I open up this directory You can see that I have an icon by default. They're gonna be 20 pixels by 20 pixels Which might be a little small depending on your application They are pixely pictures, so it's not a big deal, but you can change the height and width by giving it variables of h and w so let's do 128 and Width of 128 and there we go. We now have a 128 by 128 image I can wget that this time since it has those variables at the end I'll want to use dash o for an output and I'll just call this Av.svg for avatar and if I open you might want to do xdg I have xdg open alias to the word open But we will open up that with my default image viewer. There we go. That's what we have just downloaded now Let's write a script to Download a handful of them Obviously you don't want to overload their API, but I'm just going to write a script that anytime you run it It's going to download for avatars with the same seed But it'll give you a male a female a human and a bot so let's go ahead Vim. We'll just call this avatars.sh And we'll make this a bash script to save some time and not bore you too much I'm going to copy and paste some code here. First thing we want to do is generate a random seed We're gonna do this by I've gone over generating random characters in the past, but we're gonna cat out You random so from our dev directory. We're going to tell it. We just want alpha numeric Output and then this is going to say okay. We just want 32 characters give us the first result Okay, we just create a random seed perfect now. We want to create an array We want to generate a male a female a bot and then a random human from this information and To easily be able to adjust the size. We'll create a variable. I'll say 128 now We're gonna download the avatar right here. Let's clean this up a little bit There we go So We have our array of types. We're gonna say for each of those we're gonna create a variable called t. We're going to This did not copy the way I wanted it to there we go We can I'm putting all this on one line We don't have to but we are going to w get we're going to be quiet about it Then we're going to download a url, but we're going to put in The type here and we're going to go through each one of these types We're going to create an output file that also has That type so that's going to be part of our random seed actually that doesn't even need to be there That's actually a little extra random seed there We can actually remove that like that and we should get the same results. So we're going to generate A random seed and I think I was thinking different when I first started creating this script I could have left that stuff in there. I'm just shortening up the code a little bit with unnecessary stuff okay, so type The seed we generated and then we're gonna set the size. We're gonna set the output We're going to say the type and the seed so that we can download more than one And then we're just going to echo the output of what we just generated. That's it I'll put a link in the description of this video to this code on pasted in but let's go ahead and make that Executable, let's see right there clear the screen and now we can just type in avatars.sh and We just created a bunch of things. So let's go ahead and open up this directory here. You can see Didn't mean to move that over there We have some new avatars all 128 by 128 pixels. Let's run our code again There we go. We just got four more avatars Run it again We're gonna get four more avatars. So already we have a bunch of avatars I don't know why my computer's not liking creating some thumbnails right now properly But yeah, we can look through all these And that's great So you can actually create your own collection to have on hand as well pretty easily with a script like this Sorry for the confusion when I was Copying my script and I decided to make some changes, but again the link to this to this script, which is very simple Will be in the description of this video. I hope you enjoyed this tutorial. Please visit films by chris.com That's Chris the K. Those are linked to that in the description I do have a patreon page link in the description Please like share subscribe and I hope that you have a great day