如何使用PHP创建网页图像? [英] How do you create an image of a web page in PHP?

查看:64
本文介绍了如何使用PHP创建网页图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何用PHP渲染网页并将其另存为图像,宽度可能为600px.如何在不使用浏览器的情况下用PHP呈现页面?如何以给定的分辨率和图像格式(jpeg)保存它?该功能与Google预览相似,但不会在过渡中显示.

How can you render and save a web page as an image in PHP, probably with a width of 600px. How can I render a page in PHP without using a browser? How can I save it with a given resolution and image format (jpeg)? The functionality is similar to Google Preview, except it will not be displayed in a rollover.

类似于此问题,用C#回答.如何将网页另存为图像

Similar to this question, which is answered in C#. How to save a web page as image

谢谢!

推荐答案

您应该获得 wkhtmltoimage ,在PHP中非常容易使用:

You should get wkhtmltoimage, which is very easy to utilize from within PHP:

exec("../wkhtmltoimage --crop-w 600 http://example.com/ output.png");

还有其他选择,而不是-crop-w -width 600 然后使用GD或imagemagick.

There are other options, and instead of --crop-w or --width 600 it might be better to downscale it using GD or imagemagick afterwards.

这篇关于如何使用PHP创建网页图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆