生成 PHP 输出的图像
我想尝试创建 PHP 输出的图像/缩略图。使用它的地方是在具有各种模块的 CMS 中,然后有一个每个模块的输出外观的缩略图。这应该包括图像和所有内容。
我有什么建议/想法可以去做这件事吗?
I want to experiment with creating images/thumbnails of PHP output. A place where one would use this is in a CMS with various modules, and then have a thumbnail of how the output of how each module looks. This should include images and all.
Any tips/ideas how I would go about doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信您想要创建渲染 html 的缩略图/图像,这并不容易。因为您需要为此使用第三方屏幕截图组件。您将 html 保存在临时文件中,并向该组件传递该文件的 url,它将截取该文件的屏幕截图,然后创建您可以在自己的应用程序中使用的图像。
因为渲染效果因浏览器而异,并且明确是浏览器/客户端功能,所以我认为这不能用纯 PHP 来完成。
i believe that you want to create the thumbnail/image of the rendered html, this is not going to be easy. Cause you will need to use a 3rd party screenshot component for this. You will save the html in a temp file and pass that component the url of that file and it will take a screenshot of it and then create the image which in turn u can use in your own application.
Because the rendering would differ from browser to browser and is explicitly a browser/client feature, i dont think this can be done with pure PHP.
您需要确保 php.ini 文件中的 GD 库已打开。
然后通过 php.net 浏览 GD 库函数,了解如何操作图像。
祝你好运!
You need to make sure the GD library is turned on in your php.ini file.
Then have a surf through php.net on the GD library functions that cover how to manipulate images.
Good luck!
我刚刚在我的项目中实现了缩略图系统,因此我可以给您一些有用的提示:
I have just implemented thumbnail system in my project, so I can give you some useful tips: