Getting imagegrabscreen to work
I looked at the source to imagegrabscreen();
at this point, I believe it is failing because we both have multi-monitor set-ups.
The current code calls GetDC(0), which according to
http://msdn.microsoft.com/en-us/library/dd144871(VS.85).aspx
should return the device context for "the entire screen", but
"To get the DC for a specific display monitor,
use the EnumDisplayMonitors and CreateDC functions"
I am going to do a bit more testing of this and see if I can come up with multi-monitor-friendly code.
PHP : imagegrabscreen() not working on PHP 7.2.27
If the server is on Linux, it can't work because imagegrabscreen() is only supported on Windows:
Note:
This function is only available on Windows.
Also note that the screenshot is performed on the server. It will not capture the user screen.
PHP Using imagegrabscreen
Keep in mind that imagaegrabscreen is Windows-only. If you have multiple displays set up, this function will only grab the primary display. Also, for this to work, your Apache service must be set to Allow service to interact with desktop
otherwise you will just get a blank image.
This discussion covers the use of imagegrabscreen
pretty well: Getting imagegrabscreen to work
There are a lot of other discussions about saving webpages as images, too - here are a few:
- Website screenshots
- Web Page Screenshots with PHP?
- How can I generate a screenshot of a webpage using a server-side script?
- PHP: How to capture browser window screen with php?
- What is the best way to create a web page thumbnail?
- Screenshot of current page using PHP
- shell tool which renders web site including javascript
- In any languages, Can I capture a webpage and save it image file? (no install, no activeX)
PHP-imagegrabscreen as a method to create website-thumbnails
You'll need some interface to access a browser(s) through PHP so you can capture the image. Selenium is probably the most complete implementation of this, and it already has screenshot capturing abilities. They've also implemented distributed processing to make this process as fast as possible.
http://seleniumhq.org/docs/05_selenium_rc.html
GD2 imagegrabscreen fatal error?
You need at least php 5.2.2 or later, and php_gd2.dll
Here is a code snippet to test on your server : https://stackoverflow.com/a/4526834/1093649
And if you get a blank screen, please check Apache service privileges like stated on this php manual page comment.
Related Topics
PHP MySQL - When Is the Best Time to Disconnect from the Database
Sort Array by Value Alphabetically PHP
How to Get the Last Dir from a Path in a String
What Is the Best PHP Dom 2 Array Function
Unserialize PHP Data in Python
Check If Variable Starts with 'Http'
Mysql: Group by Two Columns and Sum
PHP Mail() Function Server and Localhost Not Working
How to Join Three Tables in Codeigniter
If I Use Captcha Will I Be Able to Stop the Spam Completely in My Blog
Setting Variables on Constructor VS on the Class Definition
Given an Email as Raw Text, How to Send It Using PHP