Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Generate a thumbnail for a given link

by Matthew.S (Initiate)
on Jul 25, 2021 at 14:31 UTC ( [id://11135380]=perlquestion: print w/replies, xml ) Need Help??

Matthew.S has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl Monks. I'm looking to write a Perl utility that will accept a link to some web page/resource and will generate a thumbnail for that web page (assuming that the given web page/resource supports it). When saying "thumbnail" I expect to generate something like say WhatsApp generates when You paste a link into it (a picture with some short text title and a link). The desired output from the utility could be an image file and a textual title in a text file that I can later use to my needs. What general approach would You suggest for me to take? Thank You for Your wisdom.

Replies are listed 'Best First'.
Re: Generate a thumbnail for a given link
by Corion (Patriarch) on Jul 25, 2021 at 14:37 UTC

    I would look at oembed and LinkEmbedder, which fetch and render link "preview" information.

    If you want to do this yourself, look at either the source code of those modules, or look at any HTTP agent for the fetching and some of the HTML parsers.

      This works like a charm. Thank You so much!!!
Re: Generate a thumbnail for a given link
by Fletch (Bishop) on Jul 25, 2021 at 14:36 UTC

    You're going to need something driving a web browser (to render the page) that you can ask to save off an image. Something like PhantomJS can do this in a headless / automated fashion. Not used it but a CPAN search does show WWW::Mechanize::PhantomJS is available.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11135380]
Approved by Corion
Front-paged by kcott
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-16 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found