http://wkhtmltopdf.org/obsolete-downloads.html
新版本依赖包比较多,我是centos5.8系统,这里使用64位老版本,同时它还用windows下的版本
wget http://download.gna.org/wkhtmltopdf/obsolete/linux/wkhtmltoimage-0.10.0_rc2-static-amd64.tar.bz2
tar -jxvf wkhtmltoimage-0.10.0_rc2-static-amd64.tar.bz2
解压后就可使用
./wkhtmltoimage-amd64 –help
- Name:
- wkhtmltoimage 0.10.0 rc2
-
- Synopsis:
- wkhtmltoimage [OPTIONS]... <input file> <output file>
-
- Description:
- Converts an HTML page into an image,
-
- General Options:
- --crop-h <int> Set height for croping
- --crop-w <int> Set width for croping
- --crop-x <int> Set x coordinate for croping
- --crop-y <int> Set y coordinate for croping
- -H, --extended-help Display more extensive help, detailing
- less common command switches
- -f, --format <format> Output file format (default is jpg)
- --height <int> Set screen height (default is calculated
- from page content) (default 0)
- -h, --help Display help
- --quality <int> Output image quality (between 0 and 100)
- (default 94)
- -V, --version Output version information an exit
- --width <int> Set screen width (default is 1024)
- (default 1024)
-
- Contact:
- If you experience bugs or want to request new features please visit
- <http://code.google.com/p/wkhtmltopdf/issues/list>, if you have any problems
- or comments please feel free to contact me: <uuf6429@gmail.com>
./wkhtmltoimage-amd64 http://www.baidu.com baidu.jpg
Loading page (1/2)
Rendering (2/2)
Done
截一张1024*1024 质量为35的jpg图片
./wkhtmltoimage-amd64 –crop-h 1024 –crop-w 1024 –quality 35 http://blog.c1gstudio.com c1g.jpg

和php结合
cp wkhtmltoimage-amd64 /opt/toolkits/
chown www:website /opt/toolkits/wkhtmltoimage-adm64
chmod 550 /opt/toolkits/wkhtmltoimage-adm64
vi /opt/php/etc/php.ini
open_basedir = “/opt/htdocs:/tmp/session:/tmp/upload:/opt/php/PEAR:/opt/php/lib/php:/opt/toolkits/”
重启phpfpm
/opt/php/sbin/php-fpm restart
vi test.php