Skip to content

Instantly share code, notes, and snippets.

@nkwhr
Last active December 25, 2015 03:59
Show Gist options
  • Select an option

  • Save nkwhr/6914136 to your computer and use it in GitHub Desktop.

Select an option

Save nkwhr/6914136 to your computer and use it in GitHub Desktop.
#!perl
use strict;
use warnings;
use Furl;
use Imager;
use Text::AAlib qw(:all);
my $url = 'https://2.gravatar.com/avatar/0e2fa4d5e82a2addb50f03414870ea46?d=https%3A%2F%2Fidenticons.github.com%2F76d9ed40d8b87622cbfa7bc12cffbcdb.png&s=420';
my $ua = Furl->new;
my $res = $ua->get($url);
unless ($res->is_success) {
die "Can't download $url";
}
my $img = Imager->new();
$img->read(data => $res->content) or die $img->errstr;
$img->write(file => "me.jpg") or die $img->errstr;
system("convert -resize 20% me.jpg me2.jpg") == 0 or die "Can't convert";
$img = Imager->new;
$img->read(file => "me2.jpg");
my ($width, $height) = ($img->getwidth, $img->getheight);
my $aa = Text::AAlib->new(
width => $width,
height => $height,
mask => AA_REVERSE_MASK,
);
$aa->put_image(image => $img);
my $aa_str = $aa->render();
$aa_str =~ s{\.}{ }msg;
$aa_str =~ s{^\s*$}{}msg;
print $aa_str;
unlink "me.jpg", "me2.jpg";
jWQQQQQQQQQQQQQQQQQQQQE`
)WWQWQQQQQQQQQQQQQQQQQQQc
_mWQQQQQQQQQQQQQQQQQQQQQWQ,
_WQWQQQQQQQQQQQQQQQQQQQQQQQQ
<QQQWQQQWQWQWQWQWQWWQQQQQQQQQ(
)WWQQQQQQQQQQQQQQQQWQQQQQQQQWWL
]WQQWQQQQWQQQQQQQQQQQWQQQWQWQWm,
jWQQQQQQQQQQQQWWQQQWWQQQQQQQQWW`
QQQQQQQQQQQQQQ(mWQB`3QWQQQQQQQQ;
jQQQQQQQQQQQQW( $WQE -$WQQQQQQQQ(
mQQQQQQQQQQWD( 3QQ[ ]QQQQQQQQQf
=QWQQQQQQQQWY dQW' )QQQQQQQQQk
jWQQQQQQQWQ[ <WW! -QQQQQQQQQk
dQQQQQQQWQQ' ]Z( dQQQQQQQQ#
3QQQQQWWQQQs, j( _swpUWQQQQQQQk
]QQQQQWQD?""4Qcj' jWV[` 4QWQQQQQf
)QQQQQQQc_, : -` - 3QQQQQQ[
WWQQQE??TYYY1a, _am2?*Iv3QQWQQQ[
3WQQQ; ~+var- #{WQQW(
]QQQWf )(-[ 3=QQQW
-$QQFA, _e ], % $QQE
]QQL ?mwaaua)' {c___<_w[ dQWf
-$QC - ""?!"?^ :QDm`
3Q( ]W(X
]W; jB:`
>4( _a _, d&-
<]L ~?><Y' d>
->< S(
)/ "
` ,___ :;
sas%"^_iii )`
-~ ~- ]
_, _ %
][ `
-C ;
-[
v, _ e
)"$a, <! 6,
) "?5s_,_a, )' WWc
wE -?T$Uf $mWL
wWE -$QWL
_aawwWm( ?Q#W6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment