Website Screenshot (HTML5 Canvas / Services) - php

Alright all,
Been doing a bit of research and want to know if anyone else has tried this... and what approach would you take.
I'm planning on doing a website which will display a screenshot of a website (maybe based on the url in someones email address).
There's going to be alot of people getting this so, pre-production of the screenshots isn't a solution.
Soooooo... does anyone know of any solutions:
Thumbnail service that builds on demand (no queuing)?
HTML5/Canvas script that will let me do this. I've found one but it won't run cross site.
Any other solution?
It'll be built in PHP.
Thanks
PVS.

This site http://html2canvas.hertzen.com/ is the best you will get right now with regard to a client side script. It uses the calculated properties of elements to render a page, and I must say it looks good!
Update:
A demo here: http://html2canvas.hertzen.com/tests/templates/projection/index.html . Click to toggle the 'real' view with the rendered image.

I've played about with wkhtmltoimage before, it was pretty good for what I was using it for, but does require you to install onto your server

For taking screenshots of websites (one of the features) i built a service ontop of the awesome PhantomJS which is an excellent headless browser which uses the webkit engine (same that safari uses). Although it's headless, it still has deps in QT and a virtual framebuffer (xvfb). Hope this helps: http://www.phantomjs.org/

You can use html2canvas. More information here.

Related

Convert webpage (html) to thumbnail/preview for output via PHP file

So i've done a lot of searching on here and Google and haven't seem to come across anything that is known to work or that I think will accomplish what i'm looking to do.
Basically right now i've been using www.thumboo.com to create thumbnails via their API however they do not support SSL and where im creating the preview is under a customer area where SSL is required.
So i'm looking to either develop something myself or find something already developed to use, i would like to create a simple "screenshot" or "thumbnail" of a website address on the fly, not sure if i want to cache it yet or not, but either way doesn't matter.
Does anybody know of any scripts out there that can accomplish this? I'm not looking to get a screenshot of the "entire" page, just what a "browser" would originally see without scrolling down, just like how it works on www.thumboo.com.
I'm not too concerned with the scripting language but i plan on outputting the file using php by pulling the file from somewhere or activating the script with java or php.
Does anybody know of any other thumbnail services that may have an API That works with SSL or any scripts that are still developed for this purpose? Everything i have found has been outdated which makes me wonder if there is some easy way to do it now with some type of function or module i may need to add to PHP.
I am server admin so i can customize PHP and the server as i need to get it to work.
Thanks ahead of time!
http://www.thumbalizr.com/apitools.php
i have never use but seems like this works for you.

How to create thumbnails or preview for links to websites?

I'd like to be able, being provided a link to a website for example, to generate a thumbnail of that website page much like does the 'new tab' page of Chrome for example.
Is it possible with PHP?
Look into using wkhtmltopdf. It is a linux binary that generates PDF/PNG images of web pages using the webkit engine.
It is not possible with PHP, but you may use PHP to call another application. Example is to use http://derailer.org/paparazzi/ on the Mac. You can call this from PHP.
you have to start a web browser on the server (via exec()), which renders the page and saves it as an image. For example you can do this with firefox and savepng plugin. With plain PHP you won't be able to do this, unless you do not implement an HTML/CSS rendering engine.
Isn't it simpler to call a webservice? http://www.webresourcesdepot.com/10-free-website-thumbnail-generation-services/
You need to have strong knowledge of Linux administration. As Darhazer posted, using exec command you can connect wkhtmltopdf, or similar tools, with PHP frontend. You also need to have a linux box, that does not have safe mode ON = this eliminate us One of these examples may be http://www.domdigger.com/screenshots/ (you can set up weekly automated screenshots for free there as well).
Hope that helps.

Hide source code in PHP GTK

i have a peculiar question.
Iam developing a php GTK2 desktop application, and my purpose is to hide the source code from the client, to whom i will handle the desktop application (deploy in his system), once it is completed.
Our motto is to enable the client to run the application, without the need for a browser.
I have heard about tools like ioncube encoder that can encrypt the php source code.
I want the same functionality to be achieved with the GTK application.
Others must not be able to see the source code. How can this be achieved ?
If you want to go the paid for route, ioncube seems good. I've found a nice article that explains this and gives you some options - it seems like Zend has the best solution if you go by price.
http://www.zubrag.com/articles/php-source-code-encoders-and-protectors.php
I hope this helps you.
I have never heard of a good free solution for this.
There is a couple of vendors providing tools to do this. By googling I found this page that presents different solutions:
http://www.seocompany.ca/software/free-encryption-software.html
I think the Alladin usb key encryption system is one of the most robust one, but not free.
And you can also make a copy of your code and remove all comments, use only non-explicit variable names etc, so that even if your customer breaks the encryption, it would still be hard to understand the code...
Hope this helps!
P

Web Page Screenshots with PHP?

I know there is not a direct way to take a screen shot of a web page with PHP. What would be the most straightforward way to accomplish this? Are there any command line tools that could do this that I might be able to execute from a PHP script (I'm thinking something that would run in a 'NIX OS (OS X and/or Linux in particular)?
Edit: Or maybe some sort of web service I could access via SOAP or REST or ...
Edit #2: I found a related question discussing the CLI option, but I'd still be open to other methods if anyone knows of anything.
See webkit2png for an OSX commandline program that does this.
The page also mentions Linux alternatives.
[edit]: wkhtml2image is the newest kid in town, and it works better then anything else i've ever used.
[edit2]: As of 2014, PhantomJS seems to be the way to go, as it has the newest webkit version of the alternatives I know about.
[edit3]: In 2019, Puppeteer is the way to go. Official headless chrome, always up to date.
You can use the GD functions imagegrabscreen() or imagegrabwindow() to take a screenshot, but they're only available on Windows at the moment.
http://www.thumbshots.org/
html2ps does a decent job for relatively simple pages, and it requires very little in terms of external binaries, meaning it's very easy to install/use. If you control the pages you'll be capturing, then you can ensure that they'll render appropriately in html2ps. If you're hoping to capture arbitrary URLs, however, I'm not sure that the PHP port of HTML2PS is up to the task. It's also not the fastest thing in the world (expect render times in the seconds for complex pages), but that doesn't really matter for some applications.
Not sure if this would be enough for you, because it has some added stuff there, but would be worth giving it a try: http://www.snap.com
It's possible to get a base64 encoded image of a site by using the Google pagespeed api.
You can specify desktop or mobile views, but you are limited to an image of a certain size.

How might I obtain a Snapshot or Thumbnail of a web page using PHP?

I need to create Snapshots / Thumbshots / Site preview a-site.com.
There are some site as thumbshot.org that meets with I need. But I do not want to use an external service, not to depend on others for my project (What would happen if they close the site?)
For this reason, I am looking for some project to let me do this.
Any idea?
On windows you can use GD's imagegrabwindow() function.
Edit: The help page actually shows you how to grab a screenshot from IE.
There isn't anything in the PHP library to do this - you're looking at setting up an external application (with a queue) to take images, although you can of course use PHP to add items to the queue.
There are a couple of Windows functions in GD that takes screen shots of the computer (webserver - not the client) so perhaps you could write a script in PHP to do this.
Edit: Was thinking of these: imagegrabscreen and imagegrabwindow. I'm not sure they will do what you want however (even in full screen mode Firefox has ablue bar at the top of the screen - not sure about other browsers). However, Pierre has something on these functions if you're interested.
I'd suggest writing an application in another language (I assume .NET has something) to do this for you.
Edit: This page tells you how to do it in C#
There's not much PHP would do for you in this situation. You'd need a complete (X)HTML rendering engine with CSS-support, possibly also with JavaScript support.
That, or use some kind of kinky script that would launch a real browser, and take a screenshot out of that. Either way, PHP is probably not the right tool for the operational part.
There's a Firefox extension that converts the webpage you're viewing to an image:
http://www.screengrab.org/
http://addons.mozilla.org/en-US/firefox/addon/1146
If you're willing to get creative, it might be possible to access this problematically.
Thanks to all.
I found a pseudo-solution, (using dcom + imagegrabscreen + wamp).
I need to resize the final.png with gd, because the png is equal to resolution of client (in my home, is a picture of 1650*1280).
Whe I end this, I will post a .zip file to dowload
Thanks again
(But if anyone have a better idea, I am happy to see that)
PS: Sorry for my english

Categories