1

Can I "convert" the website to a JPG or GIF? I mean, is it possible to view the website as an image? (obviously without animation) only a static image, like a photo of the website that the user is seeing on the browser...

Thank you!

Jeremy
  • 1
  • 85
  • 340
  • 366
Dail
  • 11
  • 1
  • Do you mean just screen grabbing the site? Or do you mean rendering the site as an image on the server and serving that to the user? (if its the latter, it might help us to know your intentions....) – joekarl Jun 09 '11 at 21:49
  • a screen of the page the user is seeing. Like a snopshot. – Dail Jun 09 '11 at 22:00

2 Answers2

1

No it is not possible, since the way the website looks is just how a browser renders it, it can be different sizes and there are many variables to the way your page looks. You can do it server-side using PHP but it won't be simple at all, it would mean your server has to have a browser that will generate the website, save it as an image on the server, and send it to the user.

Omer Tuchfeld
  • 2,886
  • 1
  • 17
  • 24
  • I wouldn't say not possible, but you're right in that the site would look dramatically different based on how the server would decide to render it.... – joekarl Jun 09 '11 at 21:52
  • Well of-course it's possible but he asked how to do it using javascript, which is impossible. And as I said, doing it server side is possible but will take too much hard work. – Omer Tuchfeld Jun 09 '11 at 21:57
  • I only want a screen, like a screenshot of the page the user is seeing on the browser... – Dail Jun 09 '11 at 22:01
  • Yes that was understood clearly, and I gave you the answer for that, try re-reading it to understood it requires A LOT of hard work and has to be done server-side. Try telling us what is the goal of this and maybe we would be able to provide you with a better solution. – Omer Tuchfeld Jun 09 '11 at 22:03
  • Agreed, with javascript there is no solution, see here http://stackoverflow.com/questions/2732488/how-can-i-convert-an-html-element-to-a-canvas-element – joekarl Jun 09 '11 at 22:06
  • hmmm I think you are wrong....take a look at clicktale.com they will "record" the page....so i think they do many screenshots. – Dail Jun 09 '11 at 22:11
  • 1
    Dail - no, they record your mouse position. Entirely different. The ONLY way to take a client-side screenshot is with a browser plugin. There are a few out there, google is your friend :) –  Jun 09 '11 at 22:12
  • @cwolves I don't think that... if you create a free account, you will see it. as you told me theY record the clickS... but these clicks are shown on a layer that show the web page. – Dail Jun 09 '11 at 22:15
  • Dail - There is ___absolutely___ no way to take a screenshot with JavaScript. I am ___100% positive___ of that, as I tried to do it while writing a web-based IDE. Even tried using Canvas to read screen pixels. You can record clicks, mouse movements, etc etc. Whatever they're doing, the data is based off of that. –  Jun 09 '11 at 22:17
  • But as I have told you, they have massive SERVER SIDE script which is way beyond your capability to control or program, it's a whole company that their goal is to do that kind of stuff, it's not simple. And it's not even close to what you're trying to achieve. – Omer Tuchfeld Jun 09 '11 at 22:18
  • @OmerPT - actually they're probably just re-firing all the events on the page by tracking mouse movements, clicks, keypresses, etc. They then play-back all of the events on a live version of the page using javascript. –  Jun 09 '11 at 22:21
  • @cwolves so they record all those information and then load the actual webpage and show them...right? – Dail Jun 09 '11 at 22:50
  • @OmerPT I know is not simple...i'm not saying that...i only what to know if this possible or not... ok i understand using js is not possible. – Dail Jun 09 '11 at 22:52
  • @Dail - I don't know how they're doing, that's just my guess as it's how I would do it. If you need a screenshot from the client, your only option is a plugin. If you just wants screenshots in different browsers, there are options like http://browsershots.org/ –  Jun 09 '11 at 22:54
  • Yes it is possible, but you must have some sort of server side browser that can take a snapshot of a website... unless you know how to get one and integrate it with whatever technology you're using for your web server it's not possible for you. Also many web pages are dynamic and taking a picture is just a weird idea, try telling us what you're trying to achieve and maybe we can help. – Omer Tuchfeld Jun 09 '11 at 22:54
  • guys I checked clicktale..com I don't know how they do it, but they have a "copy" on their server, i just upload the page and when i load the previous visits the text i have put is not shown...so they copy it each time. – Dail Jun 09 '11 at 22:56
  • @OmerPT I would like to "save" the website that the user is seeing....like clicktale, the server is not important. I don't have to develop a service like that, i only wna to do it form me....and maybe use it on my website (few visitors each day). – Dail Jun 09 '11 at 22:59
  • So from what I understood you want it to be a one time thing where you visit your website, take a picture of it, and replace the website with a picture? if that's the case just use the PrtScr button on your keyboard and paste it into a photo editing program and from there it's obvious. – Omer Tuchfeld Jun 09 '11 at 23:02
  • i would like to do it automatically...btw i understood how they did. THey download all the page! (source code) and then save a copy in hteir server... i see it from the log – Dail Jun 09 '11 at 23:06
0

Firefox added something similar to this to their canvas implementation. You can find CanvasRenderingContext2D.drawWindow() documented in their wiki. It is restricted to being used by plugins, for security purposes, and isn't supported by any other browsers.

There is talk of adding support to other browsers, and perhaps removing some of the security restrictions, but that is probably a long way off. For now, there isn't a good JavaScript solution to your problem.

Jeremy
  • 1
  • 85
  • 340
  • 366