Home>Article>Backend Development> How to use PHP to take screenshots of web pages by executing the CutyCapt command
The example in this article describes how to use PHP to capture web pages by executing the CutyCapt command. Share it with everyone for your reference, the details are as follows:
Use php to execute commands using exec
PS. By default, the exec function is disabled. Open php.ini to check whether disable_function contains this or not. If so, remove it
exec('xvfb-run --server-args="-screen 0, 1024x768x24" CutyCapt --url=http://www.jb51.net --out=2.jpg');
This One problem is that my picture only has the first screen, so I crop the picture
yum install ImageMagick
Use convert -crop to crop
convert -crop 1024x768+0+0 2.jpg 22.jpg
Use convert -resize to zoom the picture
convert -resize 15%x15% 22.jpg 22.jpg
I hope this article will be helpful to everyone in PHP program design .
For more related articles on how to use PHP to realize web page screenshots by executing the CutyCapt command, please pay attention to the PHP Chinese website!