Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert HTML to JPEG/PNG

Tags:

perl

Is there a way in Perl to get the contents of an URL in IMAGE format?

I can use LWP::Simple to get HTML, but still can't figure out how to get it in JPEG

like image 736
GrSrv Avatar asked Nov 25 '25 13:11

GrSrv


1 Answers

You could us the Wight module, which allows usage of phantomjs from Perl. An example which renders a page to a .png file would look like:

use strict;
use Wight;

my $wight = Wight->new;

$wight->visit('http://www.google.com/');
$wight->render('google.png');

Another possibility would be to use the Perl selenium API in combination with phantomjs, as described in this blog article.

like image 61
mahnkong Avatar answered Nov 28 '25 14:11

mahnkong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!