PHP uses CUTYCAPT to implement the method of capturing the screenshot of the Web page _php skill

Source: Internet
Author: User
Tags gpg svn centos

This article illustrates the way PHP uses CUTYCAPT to save a screenshot. Share to everyone for your reference, specific as follows:

Screenshot of this feature we may use the most is the QQ screenshot, or use asp.net to achieve screenshots, in fact, we can also directly use PHP to screen screenshots, here to introduce PHP using CUTYCAPT to achieve a screenshot of the process:

CUTYCAPT Download Address: http://sourceforge.net/projects/cutycapt/files/cutycapt/

Windows CUTYCAPT does not need to be installed, save it directly to your computer, and then the PHP code reads as follows:

<?php/
*
screenshot function, must be installed ie+cutycapt
URL: To screenshot of the page out
: Picture save path
path:cutycapt path
cmd: CUTYCAPT execute commands
such as: http://your php path. php?url=http://www.jb51.net
* * *
$url =$_get["url"];
$imgname =str_replace (' http://', ', $url);
$imgname =str_replace (' https://', ', $imgname);
$imgname =str_replace ('. ', '-', $imgname);
$out = ' d:/webroot/test/'. $imgname. PNG ';
$path = ' D:/webserver/cutycapt.exe ';
$cmd = "$path--url= $url--out= $out";
echo $cmd;
System ($cmd);
? >

If you are a Linux system need to simply configure the CUTYCAPT, the installation site screenshot software cutycapt.

First, install Qt47, add qt47 download source, the code is as follows:

Vi/etc/yum.repos.d/atrpms.repo
[Atrpms]
name=centos $releasever – $basearch –atrpms
baseurl=http:// dl.atrpms.net/el$releasever-$basearch/atrpms/stable
Gpgkey=http://atrpms.net/rpm-gpg-key.atrpms
Gpgcheck=1
enabled=1
[atrpms-testing]
name=centos $releasever – $basearch –atrpms testing
baseurl= http://dl.atrpms.net/el$releasever-$basearch/atrpms/testing
Gpgkey=http://atrpms.net/rpm-gpg-key.atrpms
gpgcheck=1
enabled=1
yum update
yum installqt47
yum installqt47-devel Yum Installqt47-webkit
Yum Installqt47-webkit-devel

Perhaps there will be an error message:

Warning:qt44-x11-4.4.3-10_4.el5.x86_64.rpm:header V4 DSA Signature:nokey, key ID 66534c2b
error:failed Dependenc IES:
    libglu.so.1 () (64bit) is needed by qt44-x11-4.4.3-10_4.el5.x86_64
    libmng.so.1 () (64bit) was needed by qt44-x11-4.4.3-10_4.el5.x86_64
//Resolution:
//yum-y installqt-devel*

Second, the installation cutycapt, the code is as follows:

Cd/data0/software
SVN co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt
MV cutycapt/cutycapt/usr/ Local/cutycapt
cd/usr/local/cutycapt
qmake
make

There may be an error: Make: * * * [CUTYCAPT] Error 1

Resolve: Yum update SQLite, execute make again, if it is not successful qmake-qt47 execute make again.

Third, download X-server, the code is as follows:

wget http://www.flexthinker.com/wp-content/uploads/2009/11/xvfb-run.sh.txt
mv./xvfb-run.sh.txt/usr/local/ cutycapt/xvfb-run.sh
chmodu+x/usr/local/cutycapt/xvfb-run.sh

Iv. Installation of Chinese packs

Yum Installfonts-chinese

V. Installation of ImageMagick

Yum Installimagemagick

Six, the test, the code is as follows:

/usr/local/cutycapt/xvfb-run.sh--server-args= "-screen 0, 1024x768x24"/usr/local/cutycapt/cutycapt--url=http:// Www.jb51.net--out=/tmp/163.jpg

163.jpg did not load out flash.

Seven, download 64-bit Flash plug-in, the code is as follows:

Cd/data0/software
#wget http://119.188.72.26/1/ishare.down.sina.com.cn/14036482.so?ssig=yb70xk7ph9& expires=1340899200&kid=sina,ishare&ip=1340777795,114.255.44.&fn=libflashplayer.so
http:// ishare.iask.sina.com.cn/f/13659493.html
ll/usr/lib64/mozilla/plugins/
lrwxrwxrwx 1 root root 41 06-27 14:00 libflashplayer.so->/usr/lib64/flash-plugin/libflashplayer.so
cp/data0/software/libflashplayer.so/usr/ lib64/flash-plugin/

Test load succeeded.

For more information on PHP related content readers can view the site topics: "PHP graphics and pictures Operating skills summary", "Basic PHP Grammar Introductory Course", "PHP Operations and Operator Usage Summary", "PHP object-oriented Program Design Introductory Course", "PHP Network Programming Skills Summary", "PHP array (Array) Operations tips Encyclopedia, "PHP string (String) Usage Summary", "Php+mysql Database operation Introduction Tutorial" and "PHP Common database Operation tips Summary"

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.