使用 Painty 将 HTML 转为图像文件
我正在使用画图。 http://www.rabuser.info/painty.php 到目前为止一切顺利。但我现在的问题是如何让它创建图像文件而不是将其输出到屏幕。事实上,我希望它能够在用户甚至不需要通过 AJAX 访问页面的情况下创建它。
最终,这就是它的流动方式。他们会去那里的个人资料。从那里它运行一些 ajax 并从我指定的一些 HTML 创建图像并在配置文件中显示该图像。他们还可以链接到该图像并展示它,因此我希望它成为一个文件。
I am using Painty. http://www.rabuser.info/painty.php So far so good. But my question is now how would I make it create the image file instead of outputting it to the screen. In fact I want it to create it without the user even going to the page maybe through AJAX.
In the end this is how it will flow. They will go to there profile. From there it run some ajax and create an image from some HTML i specified and display the image on there profile. They would also be able to link to this image and show it off hence the reason I want it to be a file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
之后 imagepng($im);你可以添加这一行:
如果它仍然不起作用,那么:
在 $html=@$_GET['html']; 之后添加这一行:
并在 'font_path' => 之后$__SERVER["DOCUMENT_ROOT"],
添加这一行:
我还推荐这些字体:
在 C:\Windows\fonts 中找到这些文件
After imagepng($im); you can add this line:
if it still doesn;t work, then:
After $html=@$_GET['html']; add this line:
and after 'font_path' => $__SERVER["DOCUMENT_ROOT"],
add this line:
and i also recommend these fonts:
find those files in C:\Windows\fonts
嗯,Painty 应该生成图像。确保您已按照 Painty.php 的说明正确设置标头:
最重要的部分:
header
命令告诉服务器将文件视为图像 - 甚至尽管它可能被命名为image-generator.php
。如果您也将文件视为图像,应该没问题:假设
image-generator.php
已设置为接受 $_POST 数据。然后image-generator.php
根据该数据创建一个 HTML 文件并将其作为输入发送到 Painty。祝你好运!
Well, Painty should be producing an image. Make sure you have set up your headers correctly, as per painty.php's instructions:
Most important part:
The
header
command tells the server to treat the file as an image– even though it may be namedimage-generator.php
. If you treat the file as an image as well, it should be fine:This is assuming
image-generator.php
has been set up to accept $_POST data. Thenimage-generator.php
creates an HTML file from that data and sends it to Painty as input.Good luck!