Tyler
Tyler

Reputation: 2386

generating a screenshot of a website using jquery

I would like to generate a screenshot thumbnail of any given url using strictly javascript. If this can't be done can anyone point me in the right direction to do this with my own api?

edit I just decided to cheat and use frames because it was for something I was doing for fun anyway, but thanks for all the great answers khtmltox is probably the best choice if you want to do something like this... they also have php bindings aswell.

Upvotes: 14

Views: 37071

Answers (9)

Christian
Christian

Reputation: 28124

If you look at wkhtmltox, there's native lib/app for converting a webpage to an image.

<?php // file: img.php
    $img=render_image($_GET['url']);
?>


<!-- Your Website -->

<img alt='ldr'/>

<script type="text/javascript">
    $(document).ready(function(){
        var url='http://google.com/';
        $('#img').attr('src','img.php?url='+encodeURIComponent(url));
    });
</script>

In case the comment wasn't clear enough, you need PHP somewhere which could run a native program.

Upvotes: 12

Sturt Edwin
Sturt Edwin

Reputation: 1

Need to get screenshot website see checkout this is one phpwdn.com

Upvotes: 0

Aman Virk
Aman Virk

Reputation: 3977

I recently created a REST API anyone can use to generate screenshots of websites. It is for free ( ofcourse ) and might can help you aswell.

Below are the links to some of my experiments.

Mashable ScreenShot http://storage.damnovae.com/issac/ba3d01a1ddeeb068fd365eb8468c4cd35150d143.png

Pinterest http://storage.damnovae.com/issac/f3419f73e840f2684fa15cb14154d507484b7318.png

Envato Screenshot with mobile portview http://storage.damnovae.com/issac/81c875e6622ca105db4135b19cde6b83d148b21f.png

How does it work

Get your pastiche account api key , and make post request to the api url to generate screenshots. You can read more here http://damnovae.com/pastiche

Upvotes: -1

nfo
nfo

Reputation: 647

In pure js it is not possible at moment.

I installed cutycap on my server which is responsible for generating the pictures and with some js ajax magic you can easily create your own screen shoot - thumbnail service

Upvotes: 0

Jonathan de M.
Jonathan de M.

Reputation: 9808

Bit old, but I faced the same problem and found http://html2canvas.hertzen.com/

Upvotes: 1

napster
napster

Reputation: 125

There is no way to do this in Javascript.

I believe this can be done via server-side using third-party software.
Have a look at this tutorial for more info.

Upvotes: 1

sethvargo
sethvargo

Reputation: 26997

Not gonna happen. The ONLY way you MIGHT be able to do this with JS is if the site is hosted on YOUR server and you have JS trigger to some shell script that renders the users page on your local server and saves it as an image.

You want a subscription to browser shots

Upvotes: 1

T.J. Crowder
T.J. Crowder

Reputation: 1074485

You can't do this just with JavaScript. You have to use a service like SnapCasa or similar (which basically comes down to an img tag in the right format, so it's all client-side from your perspective).

Upvotes: 0

jAndy
jAndy

Reputation: 236022

There is absolutely zero chance to do that with Javascript.

Actually, there isn't a chance at all to accomplish that with any "web"'ish technique. There might be a funky flash-app, I don't know (if that exists, one more reason to hate flash :p).

Upvotes: 1

Related Questions