Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Grab avatars for github users, use for: gource --user-image-dir .git/avatar/
#fetch Gravatars
use strict;
use warnings;
use LWP::Simple;
use Digest::MD5 qw(md5_hex);
my $size = 90;
my $output_dir = '.git/avatar';
die("no .git/ directory found in current path\n") unless -d '.git';
mkdir($output_dir) unless -d $output_dir;
open(GITLOG, q/git log --pretty=format:"%ae|%an" |/) or die("failed to read git-log: $!\n");
my %processed_authors;
while(<GITLOG>) {
my($email, $author) = split(/\|/, $_);
next if $processed_authors{$author}++;
my $author_image_file = $output_dir . '/' . $author . '.png';
#skip images we have
next if -e $author_image_file;
#try and fetch image
my $grav_url = "".md5_hex(lc $email)."?d=404&size=".$size;
warn "fetching image for '$author' $email ($grav_url)...\n";
my $rc = getstore($grav_url, $author_image_file);
if($rc != 200) {
close GITLOG;
Copy link

hangtwenty commented May 24, 2018

Thank you!!!

Copy link

OishikGuha commented Dec 31, 2020

lmao i tried the script on my directory and all it does is that it creates an avatar folder but does not save the avatar png file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment