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.
Related
I want to ask if I can run virtual server, MySQL, and a PHP editor on Android (4.1 for example)? I know my question is simple, but I didn't find anything helpful in my searches.
I use an app called Servers Ultimate, it makes life quite simple
Look into Bit Web Server (PHP,MySQL,PMA). It's a web server with PHP, MySQL as well as PHPMyAdmin - built on Android. It cost $2 and it's available on Google Play: https://play.google.com/store/apps/details?id=com.andi.serverweb&feature=related_apps#?t=W251bGwsMSwxLDEwOSwiY29tLmFuZGkuc2VydmVyd2ViIl0.
Hope that helps!
Or you can take alook at this
https://play.google.com/store/apps/details?id=de.fun2code.android.pawserver&feature=nav_result#?t=W251bGwsMSwxLDMsImRlLmZ1bjJjb2RlLmFuZHJvaWQucGF3c2VydmVyIl0.
Paw Server is able to run php , i guess by transferring the code to another server and rendering the reponse..
Have a look on my app - Android Web Developer (IDE/Code Editor for web developers). It contains a lot features e.g.
Support all major web languages and formats: PHP, JavaScript, CSS, HTML
A lot of ways to reach your project ( FTP, FTPS, SFTP, WEBDav and growing)
Code highlighting
Code completion
Error checking
Hardware keyboard support (e.g hotkeys)
Code beautifying with one click
Tablet ready UI
Line numbering
Quick preview of your page
Highlighting the current line
Search and replace with regular expressions
Unlimited Undo/redo
Full screen mode
Recent projects
Periodical autosaving
Rename/create/delete/copy-paste files inside you project
Hope this helps.
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.
I need a server-side script (PHP, Python) to capture a webpage to a PNG, JPG, Tiff, GIF image and resize them to a thumbnail.
What is the best way to accomplish this?
See also:
Web Page Screenshots with PHP?
How can I take a screenshot of a website with PHP and GD?
How might I obtain a Snapshot or Thumbnail of a web page using PHP?
You can probably write something similar to webkit2png, unless your server already runs Mac OS X.
UPDATE: I just saw the link to its Linux equivalent: khtml2png
See also:
Create screenshots of a web page using Python and QtWebKit
Taking automated webpage screenshots with embedded Mozilla
What needs to happen is for a program to render the page and then take an image of the page. This is a very slow and heavy process but it can be done in PHP on Windows.
Also check the comments in the documentation article.
For python I'd recommend reading this article. It highlights some of the solutions.
There are services you can also call (via some API) that will return you an image. But usually they cost (WebShots for example)
You'll need to:
read the webpage and all the its multimedia content (images, flash, etc)
utilize a browser rendering engine to render the webpage
take a screenshot and save it as image
first and third steps are easy, the second step is more challenging ;)
If you are using php, you could use imagegrabscreen (PHP 5 >= 5.2.2). Imagegrabscreen: captures the whole screen.
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.
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