/    Sign up×
Community /Pin to ProfileBookmark

is there a way that php takes a screenshot of a page?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiJul 31.2009 — Not directly. A page is rendered by a browser (client), and since PHP is executed on the server it knows nothing of browsers. You [I]could[/I] use PHP to issue sys commands to open a browser on the server and take a screenshot, but it won't make for very portable code.
Copy linkTweet thisAlerts:
@moiseszaragozaauthorJul 31.2009 — thanks for the help.

what i need to do is have PHP take a screen shot of a page on the same server that way i can use that image to something else and then dispose of the image
Copy linkTweet thisAlerts:
@MindzaiJul 31.2009 — Well like I say PHP can't do that itself because how a webpage appears is down to the browser. You will need to send system commands for your OS to execute which will open the browser at the right URL and take the screenshot.
Copy linkTweet thisAlerts:
@moiseszaragozaauthorJul 31.2009 — by any chance would you know how that can be done?
Copy linkTweet thisAlerts:
@MindzaiJul 31.2009 — It really depends on your OS and the software you have installed. It isn't really a PHP issue as all you are doing is executing commands as if using a terminal. For example, on the machine im typing this on (Debian Linux with ImageMagick & Firefox installed), the following works:

[code=php]
<?php

exec("firefox 'http://www.google.com'");
exec('sleep 10'); // give the browser time to open and load the page
exec('import -window root ~/cap.png');

?>
[/code]


But move it to another machine and it may not which is why you will have difficulty moving this code around. If that isn't an issue though then you should be set.
Copy linkTweet thisAlerts:
@moiseszaragozaauthorJul 31.2009 — Thanks,

that code helps me alot.

Well its a starting point on doing what i need to do

i do really apreacite the help
×

Success!

Help @moiseszaragoza spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...