當初會想要使用這個功能,是不打算讓使用者自行上傳網站圖片,可能會出現使用者亂上傳或不上傳,而不上傳又會造成資訊不完整,所以只能限制用程式來自動產生嘍!
找了許多資料,發現在Windows環境下的Apache Server可以輕鬆完成,利用IE + com元件可以輕鬆拍照成功,例如:WebPageGrabber(imagegrabwindow),但是在Linux上,卻無該方法可以使用,在遍尋不著範例之下,只有自己整合資料來達成了,我發現了許多人事實上有實作,但是卻沒有很完整的交待所有有可能在安裝時所發生的問題,基於我很健忘的理由,所以又把他記錄在BLOG上,順便可以回憶,也可以分享給大家!
測試套件:
CutyCapt
http://cutycapt.sourceforge.net/
註:他很簡單的說明了一下,但是安裝時問題蠻多的,所以才會產生這篇!
實作環境:
Linux Fedora Core 9
Without X Server
需求安裝:
Qt
gcc-c++
subversion
安裝步驟:
1、首先利用Yum套件安裝以下所有套件
# yum -y install subversion qt-devel qt-config SDL-devel gcc-c++ Xvfb
2、切換至您想安裝存放的目錄
# mkdir /path-to-you-want-to-installed
# cd /path-to-you-want-to-installed
(/path-to-you-want-to-installed 是由您自行決定命名)
3、取得CutyCapt套件並存放至指定目錄
# svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt
4、進入安裝目錄
# cd cutycapt/CutyCapt
5、執行安裝
這裡需要qmake跟g++套件,已經在第一步驟全部安裝。
# /usr/local/bin/qmake
# make
6、設定xvfb-run
這裡我並不知道為什麼他沒有自動預設安裝,但可以在Source裡找到,這裡已經有提供,請下載回去解開後將其放至 /usr/local/bin裡以利套作使用(此為使用者無進入 X Server時使用,因為是要給網站程式用,所以必須一定要使用此方法來虛擬運行並利用qt拍照)
# mv xvfb-run /usr/local/bin
# chmod +x /usr/local/bin/xvfb-run
下載:xvfb-run.rar
安裝完畢。
使用方法:
使用指令為
/usr/local/bin/xvfb-run /path-to-you-want-to-installed/cutycapt/CutyCapt/CutyCapt -f /tmp/path-to-your-temp --url=http://you.want.to.photo --out=/out-photo-to-dir-name
產生全站大小約需15~20秒左右,以下有其它參數資料,請參考:
% CutyCapt --help
-----------------------------------------------------------------------------
Usage: CutyCapt --url=http://www.example.org/ --out=localfile.png
-----------------------------------------------------------------------------
--help Print this help page and exit
--url=<url> The URL to capture (http:...|file:...|...)
--out=<path> The target file (.png|pdf|ps|svg|jpeg|...)
--out-format=<f> Like extension in --out, overrides heuristic
--min-width=<int> Minimal width for the image (default: 800)
--max-wait=<ms> Don't wait more than (default: 90000, inf: 0)
--delay=<ms> After successful load, wait (default: 0)
--user-styles=<url> Location of user style sheet, if any
--header=<name>:<value> request header; repeatable; some can't be set
--method=<get|post|put> Specifies the request method (default: get)
--body-string=<string> Unencoded request body (default: none)
--body-base64=<base64> Base64-encoded request body (default: none)
--app-name=<name> appName used in User-Agent; default is none
--app-version=<version> appVers used in User-Agent; default is none
--user-agent=<string> Override the User-Agent header Qt would set
--javascript=<on|off> JavaScript execution (default: on)
--java=<on|off> Java execution (default: unknown)
--plugins=<on|off> Plugin execution (default: unknown)
--private-browsing=<on|off> Private browsing (default: unknown)
--auto-load-images=<on|off> Automatic image loading (default: on)
--js-can-open-windows=<on|off> Script can open windows? (default: unknown)
--js-can-access-clipboard=<on|off> Script clipboard privs (default: unknown)
-----------------------------------------------------------------------------
<f> is svg,ps,pdf,itext,html,rtree,png,jpeg,mng,tiff,gif,bmp,ppm,xbm,xpm
-----------------------------------------------------------------------------
http://cutycapt.sf.net - (c) 2003-2008 Bjoern Hoehrmann - bjoern@hoehrmann.de
那要如何使用在PHP上呢,請看一個小範例....
<?php
// 要截圖的網址URL
$url = 'http://you.want.to.photo/';
// 要輸出的路徑
$outpath = /out-photo-to-dir-name/
// 要輸出的圖片名
$outname = 'test.png'; // 也可以用 .jpg等其它格式
// 程式定義
$progpath = '/usr/local/bin/xvfb-run /path-to-you-want-to-installed/cutycapt/CutyCapt/CutyCapt';
$cmd = "$progpath --url=$url --out=$outpath/$outname";
exec($cmd);
?>
搞定....收工.....





31/08/2010, 15:47
LYQLL20100831 The north face jacket index of leading economic indicators is basically flat. We could see north face outlet zero or very little growth for the rest of the year. And while mens north face jackets sale the last two months job surveys showed losses mainly because of the end to hiring for mens north face down jackets the census, we could see continued losses, if these weekly jobless claims north face winter gloves stay this high.The rule of thumb in the economic world is that weekly north face backpacks sale initial jobless claims must be in the 300,000 range in order to get to actual women north face jackets job growth. Democrats regained 26 seats in the House, although they split even cheap north face jackets in the Senate. http://www.northfaceouletstore.com/
29/08/2010, 15:19
Learning 11August LYP mathematics is to explore timberland boots
the mysteries of the universe. If know, star formation, heat and electricity with existing laws,timberland boots sale
variation and mathematical truth, all involved. If language reflect and reveals the creator's voice,timberland 6 inch boots
mathematics and reveals the creator of wisdom, and repeatedly repeats how things change into existence story. Mathematics timberland roll top boots
and guide our energy, self-esteem and desire to know the truth, and the life of god and in the land.As timberland chukka boots
the literature to induce people to understand, emotion and inspire people to imagine mathematics mens timberland boots
and reasoning.Labor is a magic power of folk pedagogy, give us the wisdom
of education opened up new source. This source of education theory book does not know. We firmly believe mens 6 inch timberland boots
that only through perspiration, there are timberland classic boots
weary and callosity of labor, people will become sensitive and tender.Through labor, cheap timberland boots
talent is to use the mind world around them.
27/08/2010, 17:39
The Tanabata night, MBT Shoes Clearance couples from ships travelled to south chan, experience and galactic han romantic artistic exchange, then in bridge street hand softly, burning fireworks, MBT Chapa Shoes put the lights of the traditional culture, the couple could interest to the ancient kiln museum together to make a symbol of love, like MBT M.Walk Shoes rock brick souvenirs. Then, MBT Lami Shoes in the generation of red large stakes in residence to gain experience through MBT Sport Shoes accessories. 27 August CHF
25/08/2010, 22:40
I really want to thank you very much for your hot story just about this topic. I think that you require the assistance of an experienced article submission service or some different article submission to do your topic telling.
25/08/2010, 19:38
Frequently, students are willing their research papers to be non-plagiarized. Nonetheless, people do not understand how to realize it! I can give a gentle hint! Guys have to come to the custom term paper writing services. Good paper writers should surely solve such things.
22/08/2010, 01:10
Don’t have got an experience of essays creating? Don't panic! Just purchase academic custom essay service and be assured that professionals will be able to offer solid quality issues!
30/10/2009, 18:59
这技术收下了.