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]…
Description:
Converts an HTML page into an image,
General Options:
–crop-h Set height for croping
–crop-w Set width for croping
–crop-x Set x coordinate for croping
–crop-y Set y coordinate for croping
-H, –extended-help Display more extensive help, detailing
less common command switches
-f, –format Output file format (default is jpg)
–height Set screen height (default is calculated
from page content) (default 0)
-h, –help Display help
–quality Output image quality (between 0 and 100)
(default 94)
-V, –version Output version information an exit
–width Set screen width (default is 1024)
(default 1024)
Contact:
If you experience bugs or want to request new features please visit
, if you have any problems
or comments please feel free to contact me:
./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
exec(/opt/toolkits/wkhtmltoimage-amd64 --crop-h 1024 --crop-w 1024 --quality 35 http://blog.c1gstudio.com c1g.jpg);
?>