Is it possible by any way to make a .php with all the data into it a .png

Example:
You got a php that the data displays in the order you want and u
want to like screenshot it and post it into the main .php
like a fucntion createphptoimg("test.php")

Do you mean create an image from a php page that outputs image data, or create an image from a php page that just outputs data?

The first case is easy, just put header('Content-Type: image/png'); at the top. The second one is a bit strange.

Member Avatar for diafol

Am I correct in thinking that you want to make a 'screenshot' of how the derived html would look? Are you trying to create thumbnail image of a page? If so, I don't think it can be done without a hell of a lot of work.

php just spits out data as you've mentioned. It has no idea how the browser is going to render the page as colours, widths etc. It's the browser that does all the work of retrieving images, javascript, styles etc. Without the browser being involved, I can't see how php could create an image. Even with ajax, I can't see how it could be done. Javascript is pretty much blocked from getting screenshots of the client's machine (AFAIK). Could be embarrassing!

There are some sites that offer a service. Can't remember what they're called - thumbshots or something?

As SCP states, you can use gd or imagemagick to create images in a php file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.