Creating a user image template, id, stackoverflow.com

Stackoverflow.com users who do not upload their photos have an image pattern in their photo area. They are simple but different for all users, and it is very impressive. Each of them has a central square and an outer border, both usually filled with patterns. Is the code to create these image templates or how can they be created? Can they be created in R?

+6
source share
1 answer

Calculate the hash of the digest email address:

 d <- digest(' ab@c.com ', algo='md5', serialize=FALSE) d ## [1] "b1554c62bf1d05a4a9c48754a6619c17" 

Then ask gravatar for the image:

 download.file(paste0('http://www.gravatar.com/avatar/', d, '.png?d=identicon'), mode='wb', destfile='ab.png') ## trying URL 'http://www.gravatar.com/avatar/b1554c62bf1d05a4a9c48754a6619c17.png?d=identicon' ## Content type 'image/png' length 2280 bytes ## opened URL ## ================================================== ## downloaded 2280 bytes 

enter image description here

Windows systems require mode='wb' . mode='w' by default, and the b flag is ignored on systems other than Windows.

+7
source

Source: https://habr.com/ru/post/971157/


All Articles