PHP sample code for implementing web page screenshots by executing the CutyCapt command

怪我咯
Release: 2023-03-13 20:22:02
Original
1432 people have browsed it

When taking screenshots of the website, CutyCapt, a tool of the server, is used. You can directly use commands on the server to capture and generate pictures of the specified URL. However, when using php to execute system commands, it was found that it could not be executed, but commands with help information such as CutyCapt ("/usr/local/cutycapt/CutyCapt/xvfb-run.sh --help") could be executed, but the call was executed# The script of ##System Variables failed. I suspected that it was a permissions issue. I later set the CutyCapt permissions to www, but found that it didn't work. After searching for information, I found that the nginx server would call a shell script when executing the command, and then encounter a permissions problem.

This article mainly introduces the method of

php to realize the web page screenshot by executing the CutyCapt command. It analyzes the related operation skills of php to realize the web page screenshot function by executing the CutyCapt command through exec. Friends who need it You can refer to the following

Use php to execute commands using exec

PS. By default, the exec

function is disabled. Open php.ini to check disable_function Whether to include this or not, if so, remove one of the problems

exec('xvfb-run --server-args="-screen 0, 1024x768x24" CutyCapt --url=http://www.jb51.net --out=2.jpg');
Copy after login

My

picture only has the first screen, so crop the picture

yum install ImageMagick
Copy after login

Use convert -crop for cropping

convert -crop 1024x768+0+0 2.jpg 22.jpg
Copy after login

Use convert -resize for image scaling

convert -resize 15%x15% 22.jpg 22.jpg
Copy after login

The above is the detailed content of PHP sample code for implementing web page screenshots by executing the CutyCapt command. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!