Avatar of CongUan
 asked on

Convert HTML to Image

Hi Experts,

How can I convert HTML source to image (Run-Time on Server) by PHP language ?

Avatar of undefined
Last Comment

8/22/2022 - Mon

Converting HTML to an image implies rendering the HTML, a task which is usually done on the client side by the browser. Unless you find a way to encapsulate Mozilla into a php class, I don't think this can be done.

Sorry, Jan

What do you need?

It has non sense to convert to image something that is normally done by a browser...
Let me know

This can be done but you'd most likely need your own server dedicated for it..

PHP can run commands in the command line..

so you can make a script that would take the input of a form which would tell it what page to use and which browser to open it under.

the php script would launch the browser with that page through command line, then call the screenshot utility and save it to a path accessible to the server and return a path.

There are other things out there such as http://khtml2png.sourceforge.net/ to do so.

I don't think making one from scratch would be too hard. You just have to find a screenshot utility which you can run from command line and time it a certain amount of time after the launch of the browser.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Sathallrin: "You cannot do this entirely with PHP, you would have to setup some programs on the server using one of these packages"

It's better to be sparing for setup some programs on the web server using one of these packages. No more any other solution ???