TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How to Convert HTML to PNG on a Serverside?

13 点作者 Fruzenshtein超过 5 年前
Hello everyone!<p>I need an advice. I work on a web app, that needs to send PNG images to users based on their achievements. The easiest way to do that is to construct an HTML that contains all the information, make a screenshot of it and finally upload it to the server. But this solution is extremely not optimal.<p>So I&#x27;m curious how to implement the same logic, but without frontend involvement in terms of image generation. I know that there are many commercial libs and services for that, but maybe there is some open-source more or less good libs for that.<p>I&#x27;m fine to work with Java, Scala, NodeJS or Golang.<p>Any advice is welcome!

7 条评论

j45超过 5 年前
Not quite HTML, another way to similar output:<p>Both of the below should have a library you can use to generate the text into an image, if you don&#x27;t want to work with them directly.<p><a href="http:&#x2F;&#x2F;www.graphicsmagick.org" rel="nofollow">http:&#x2F;&#x2F;www.graphicsmagick.org</a><p><a href="https:&#x2F;&#x2F;imagemagick.org&#x2F;index.php" rel="nofollow">https:&#x2F;&#x2F;imagemagick.org&#x2F;index.php</a>
jeanvalmarc超过 5 年前
<a href="https:&#x2F;&#x2F;wkhtmltopdf.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;wkhtmltopdf.org&#x2F;</a>
评论 #21699963 未加载
评论 #21709710 未加载
onesmallcoin超过 5 年前
I&#x27;m currently bootstrapping an api&#x2F;sass that takes any url and converts it to an image. It runs on top of chromium and uses the CDP protocol to do cool things like automate basic auth, custom http headers, injected js, mock mobile templates and device emulation, custom interactions with the webpage, it can also return json or upload the results to dropbox, s3, or google cloud storage. I&#x27;m looking to chat with people interested in this kind of technology as I polish off the final touches on the API and get the product live!<p>What kind of features would be useful to you if you were to go the API route for something like this?
dustinmr超过 5 年前
This arrived in my RSS feed today. Seems to fit the bill.<p><a href="https:&#x2F;&#x2F;www.thepolyglotdeveloper.com&#x2F;2019&#x2F;12&#x2F;generate-images-from-html-with-gulp-and-puppeteer&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.thepolyglotdeveloper.com&#x2F;2019&#x2F;12&#x2F;generate-images...</a>
Grazester超过 5 年前
There are libraries for converting HTML to PNG. Why would you need the frontend for anything?<p>Grab the users&#x27; achievement from the database(I could only assume user data is stored here). Format it however you want it to look in an HTML file then convert said HTML to a PNG. Its dead simple.<p>I did the equivalent but with PDF&#x27;s for customer bills for a past job.
评论 #21696460 未加载
perilunar超过 5 年前
Does it need to be HTML? SVG is easy to generate programmatically, and doesn&#x27;t need to be converted.
评论 #21699960 未加载
chriskinsman超过 5 年前
Headless chrome&#x2F;puppeteer...
评论 #21696505 未加载