I should have known better. It was just 2 hours (plus blog post writing time) down the coding rabbit hole.
Right now Ken Bauer is working on the Virtually Connecting blog post for the sessions they (me too) will run at the 2016 DML Conference. If you look at the announcements you will we create an image that includes the faces/icons of participants. It’s nice, it shows the people well.
But getting the avatars means searching in twitter, going to profile, another click on the image, and… well is tedious. I wondered first if there was a web tool, so went into the Choral Explanation of Google results. The ones I found were a few years old, likely used the defunct API 1.0 — e.g. http://tweetimag.es/ just produced eggs and http://twivatar.org/ was a defunct domain (you could not tell from GitHub old repo).
Digging back in the results I found it in the usual place, Stack Overflow. But then I found a post that showed it was as easy as constructing a URL that access the public methods of the 1.1 API.
1 |
https://twitter.com/[screen_name]/profile_image?size=[size] |
where size can be “mini”, “normal”, “bigger”, or original.
So mine is
1 |
https://twitter.com/cogdog/profile_image?size=normal |
Which produces
I wondered what it would take to build a web tool for others to do that, just a bit of jQuery interaction with a form, so that changing the sizes from a menu, entering a twitter name would generate the image and a download link. And reading the Twitter documentation on Profile Images and Banners I found the URLs that could be used to represent the default “eggs”
1 2 3 4 5 |
https://abs.twimg.com/sticky/default_profile_images/default_profile_1_normal.png https://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png : : https://abs.twimg.com/sticky/default_profile_images/default_profile_6_normal.png |
Producing…
Thus I was able to generate a different colored egg in each page load. Why? Because I can.
Then I enter a twitter name, like bali_maha click Get Avatar. Oh it’s small. Of course, it’s an icon. I’ll take the original, please.
She’s no egg, but now it’s a one click to download the image.
The one page of HTML code, with comment seasoned Javascript, is in the cupboard.
Top / Featured Image: flickr photo by Garrett Heath https://flickr.com/photos/garrettheath/9359575921 shared under a Creative Commons (BY) license
Love this over-easy option! It will also ensure we keep up with the catch, when people change their avatar.