Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically determine if a GitHub account uses the default profile picture (avatar)?

When a GitHub user signs up for an account, GitHub provides a default profile picture that looks something like this:

enter image description here

The user can set a custom profile picture based on instructions here.

The way I can think of is to download the current profile picture from the GitHub user, then download his default profile picture from https://github.com/identicons/USERNAME.png . Then compare these two pictures. But this solution is not beautiful.

Is there a beautiful way to determine whether a GitHub user uses the default profile picture or has set a custom profile picture? Like a boolean value I can check or something like this. Thanks.

like image 958
hsluoyz Avatar asked Oct 29 '22 17:10

hsluoyz


1 Answers

GitHub would use the Gravatar service in order to fetch an image associated to a GitHub user email account.

You can query such an image through the Gravatar API. If there is none, that means a default auto-generated image will be used.

When there is no picture associated to an email, GitHub use the ?d=identicon parameter to generate a geometric pattern based on the email hash:

https://www.gravatar.com/avatar/05b6d7cc7c662bf81e01b39254f88a49?d=identicon

like image 184
VonC Avatar answered Nov 23 '22 23:11

VonC