从 DIV 创建图像

发布于 2024-11-29 21:46:32 字数 262 浏览 1 评论 0原文

我搜索了 Google 和 Stackoverflow,但似乎无法给出明确的答案。

我想根据特定的内容创建图像。所以我有一个 div,我在其中添加了图像、文本、背景颜色等,并且我想将该 DIV 保存为图像。我读过 GD 以及如何创建每个单独的位,例如首先创建画布,用颜色填充它,渲染字体等...... 我想知道,难道没有更简单的方法吗?这似乎是一项简单的任务,但我很欣赏事实并非如此。您可以推荐一些可以帮助实现此目的的库吗?而不必在画布上渲染每个图像、每个文本和每种颜色。

谢谢

I've scoured Google and Stackoverflow and can't seem to come up with a definitive answer.

I'm wanting to create an image from a particular bit of content. So I've got a div which I've added images, text, background colours etc. to and I'm wanting to save out that DIV as an Image. I've read on GD and how to create each individual bit, like creating the canvas first, filling it with a colour, rendering the fonts etc...
What I'm wondering, is there not an easier way? It seems like a straight forward task but I appreciate it's not. Are there any libraries that you could recommend that will aid this? Rather than having to go through rendering each image, each bit of text and each colour on the canvas..

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眼泪也成诗 2024-12-06 21:46:32

PHP 不知道你的页面是什么样子。

这就是浏览器/用户代理所做的事情(呈现 HTML)。

查看:使用 PHP 的网站屏幕截图

PHP has no idea what your page looks like.

That's stuff a browser / user-agent does (rendering HTML).

Check out: Website screenshots using PHP

半仙 2024-12-06 21:46:32

div 不是图像。在现实世界中,它是一个用来装杂货的塑料袋。您想要的是一个 对象,可以使用各种 JavaScript 函数将其内容捕获为图像。

A div is not an image. In real world terms, it's a plastic bag you put groceries into. What you want is a <canvas> object, the contents of which can be captured as an image using various javascript functions.

梦年海沫深 2024-12-06 21:46:32

如果您正在寻找用于放置广告的在线图片编辑器,svg-edit可能适合您的要求。这应该能让你最顺利地到达那里。

还有一些服务可以完成这项工作,您甚至可以将其用作第三方工具。我相信您也能体会到它们的复杂性。

If you're looking for an online image editor to lay up ads, svg-edit may suit your requirements. This should get you most the way there.

There's a few services around too that do the job and you may even be able to leverage as a 3rd-party tool. I'm sure you can also appreciate their complexity.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文