Html to jpeg as thumbnail [duplicate] - php

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Website screenshots using PHP
Can someone tell me how to take a thumbnail off of a web page using php or js without any 'API' support? Otherwise convert HTML to PS and PS to jpeg is also possible.
Thank you.

Try Phantom JS. It can be used to render HTML from the commandline, using various output formats. Creating a thumbnail can be done by setting the zoom factor.

WKHtmlToImage is able to render a webpage using webkit engine. You will have to launch an executable on server-side though.

Related

how to convert html code to png image using php [duplicate]

This question already has answers here:
Convert HTML to Image in PHP without shell
(5 answers)
Closed 6 years ago.
Is there a php script that allow to convert a html code to a png image.
The problem with GD library is that only convert text to image( and not html code )
There is no pure PHP solution to this.
Basically you've got two options:
Client-side rendering
Use something like html2canvas to render your image using javascript in the browser.
Server-side rendering
Use a library like wkhtmltopdf which can be invoked by PHP to generate the image.
Another server-side solution would be using Phantom.js which can also run javascript before capturing the screen.

Create an image from an url using PHP GD [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to save webpage as a image file using PHP?
I would like to create an image on the server using a url string that is given.
I want a screen shot of a website to be created.
Is it possible with PHP GD , if so how ?
Thanks
You need something like PhantomJS to do it. This can be called from PHP.
Pretty sure GD can't handle this by itself. You'd need an HTML renderer too.
As far as I know, there is no existing PHP-Lib, which can do this. PHP-GD has to do with graphics, but you cant do this with it. Even if: What will happen, if the Site uses Javascript to enable certain important parts of a site? Or even images or other resources, that require long running requests? Or consider sites using flash... There are some tools for linux to take screenshots in batch - configurable with timer etc.

How to make pdf of html page of invoice? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Create a PDF file with PHP
I have created invoice generator using javascript. well I am able to work on it. Now what I have to do is I have to generate the data in the pdf which are available in the invoice. I tried some but none work out. So If there is anyone who can help me out?
Thanx in advance
I have used "webkit html to pdf" (wkhtmltopdf) several times.
It worked well for me, although working with page breaks is a bit of an hassle.
PDF cannot be generated at the client side (I mean with Javascript). You will need to process the invoice data at the server side using a PDF library and write to a URL location, so that it can be downloaded or opened in a browser.
TCPDF is a good tool to generate PDF with PHP. See this link.
Also see this question.

Converting HTML to an Image [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
Convert URL to screenshot (script).
PHP: How to capture browser window screen with php?
I have a URL and I want to convert that webpage screenshot to an image. Please let me know if we can do this using php or some other tools that can be used with PHP/Linux.
This isn't the best solution, but you could convert the HTML page to a PDF, then use imagemagick to convert the pdf to a jpeg using this command exec("convert sample.pdf sample.jpeg"). To convert HTML to pdf, see this question.
Convert HTML + CSS to PDF with PHP?
The shutter screenshot tool is able to do that.
It's in the menu: File -> New -> Web
Can be used with Linux and PHP on the same system. See the manpage for commandline options to be invoked from PHP.

How to convert HTML to image with PHP [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Screenshot of current page using PHP
How to convert HTML to image with PHP , have idea!!!
If you have Python, PyQt4 and Webkit installed on your server, you can use Webkit2PNG to do this: it downloads the page, fires up the Webkit rendering engine, and takes a snapshot.
Note that this could be resource-intensive; also, rendering can differ in various browsers (and in IE).
In order to get an image of a web page, you need software that can render a web page (that is, lay out elements, apply styles, and so on). Such software is typically called a "browser".
It's possible to automate a browser from PHP, using COM (like in sAc's answer) on windows, for example.

Categories