use WWW::Mechanize::PhantomJS; my $mech = WWW::Mechanize::PhantomJS->new(); $mech->get('http://google.com'); $mech->eval_in_page('alert("Hello PhantomJS")'); my $png = $mech->content_as_png(); print $png; # I added this line so the PNG image is sent to STDOUT