Ask HN: How to Convert HTML to PNG on a Serverside?
13 points| Fruzenshtein | 6 years ago
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.
So I'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.
I'm fine to work with Java, Scala, NodeJS or Golang.
Any advice is welcome!
j45|6 years ago
Both of the below should have a library you can use to generate the text into an image, if you don't want to work with them directly.
http://www.graphicsmagick.org
https://imagemagick.org/index.php
jeanvalmarc|6 years ago
Fruzenshtein|6 years ago
4d66ba06|6 years ago
onesmallcoin|6 years ago
What kind of features would be useful to you if you were to go the API route for something like this?
dustinmr|6 years ago
https://www.thepolyglotdeveloper.com/2019/12/generate-images...
Grazester|6 years ago
Grab the users' 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.
I did the equivalent but with PDF's for customer bills for a past job.
Fruzenshtein|6 years ago
perilunar|6 years ago
Fruzenshtein|6 years ago
chriskinsman|6 years ago
Fruzenshtein|6 years ago