把一段文字转成图片,比如常用的长微博工具,这里用PHP处理。text2piccomposer需要dsgygb/text2pictouchtest.phpgenerate("helloworld");print_r($result);#中文字体路径/c/windows/fonts/sihei.ttf$transform=newText2pic\Transform($by,$uploadsPath,$uploadsUrl,$fontPath);下载wkhtmltopdf地址后,有2个工具wkhtmltoimage和wkhtmltopdf,分别是将网页转成图片和pdf。具体用法参考#生成图片https://gist.github.com/vibbow/5702882/user/bin/wkhtmltoimagehttp://www.baidu.com/baidu.jpg#php使用绝对路径调用$r=shell_exec("/user/bin/wkhtmltoimagehttp://www.baidu.com/baidu.jpg");$r=shell_exec("/user/bin/wkhtmltoimage-q{$filename}.html{$filename}.jpg");phpwkhtmltopdf#一个PHP库https://github.com/mikehaertl/phpwkhtmltopdfcomposerrequiremikehaertl/phpwkhtmltopdfrequire'./vendor/autoload.php';usemikehaertl\wkhtmlto\Image;//可以传一个文件名,一个HTML字符串,一个URL或一个选项数组到构造函数$image=newImage('/path/to/page.html');$image->saveAs('/path/to/page.png');//save//...或发送到客户端进行内联显示$image->send();//浏览器显示//...或者作为文件下载发送给客户端$image->send('page.png');//浏览器显示并下载#另一个库https://github.com/knplabs/snappyuseKnp\Snappy\Pdfasnewpdf;$snappy=newnewpdf('wkhtmltopdf');header('Content-Type:application/pdf');header('Content-Disposition:attachment;filename="file.pdf"');//echo$snappy->getOutput('http://www.github.com');$snappy->generateFromHtml('
Bill
你欠我钱,伙计。
','bill-123.pdf');more生成恶棍持牌图片https://github.com/jokin1999/HoldUpSignhttps://stackoverflow.com/questions/5663814/how-do-i-get-wkhtmltopdf-to-execute-via-phphttp://www.jianshu.com/p/4d65857ffe5ehttp://yuncode.net/code/c_51dd01a4d547f26https://github.com/niklasvh/html2canvas网页另存为图片和高清截图优化https://segmentfault.com/a/1190000011425316