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
–crop-w
–crop-x
–crop-y
-H, –extended-help Display more extensive help, detailing
less common command switches
-f, –format
–height
from page content) (default 0)
-h, –help Display help
–quality
(default 94)
-V, –version Output version information an exit
–width
(default 1024)
Contact:
If you experience bugs or want to request new features please visit
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);
?>
No Responses (yet)
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.