CSS PNG using PHP?

I would like to ask if it is possible to take some CSS on a page with a PHP extension and add a PHP header to define the page as PNG and have a dynamic image? From what I heard, this is not possible, but if it is not, is there a simpler way than the usual method of creating a PHP image?

Edit * To clarify, I want to do something like drawing a 200x200p frame in CSS with style and HTML and have this HTML / CSS window on the .PHP page and get this page to become a .PNG PNG image using the Header PHP tag.

Thanks!

Karan

+4
source share
2 answers

You can use wkhtmltopdf , which can convert html to pdf using webkit (qtwebkit), which correctly supports CSS. There is even a PHP binding for it .

You can then convert the PDF file to PNG (for example, using ImageMagick) and execute it with PHP.

Related: screenshots on a site using PHP

+3
source

If I understand your question correctly, I'm not sure how this is possible using only PHP, but you can use ImageMagick on the server to convert the HTML page to png.

+2
source

Source: https://habr.com/ru/post/1388054/


All Articles