Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mermaid PNG support #507

Closed
andreas-globi opened this issue Nov 26, 2020 · 4 comments
Closed

Mermaid PNG support #507

andreas-globi opened this issue Nov 26, 2020 · 4 comments
Labels
👶 good first issue Good for newcomers 🍩 enhancement New feature or request 📜 javascript Related to Javascript code

Comments

@andreas-globi
Copy link

It would be awesome if there were PNG support for Mermaid charts. SVG is not as usable from an API point of view.

@ggrossetie
Copy link
Member

For reference, Mermaid CLI is using screenshot from Puppeteer to generate a PNG image: https://github.com/mermaidjs/mermaid.cli/blob/46185413d75384cd7bceed802d187db6852f5190/index.js#L113-L117

@andreas-globi
Copy link
Author

I don't understand what that means. The return is an SVG and not a PNG. Renaming it to PNG doesn't help either. Internally it's not PNG data. (sorry - don't know much about puppeteer if I'm missing something obvious here). And pushing the result into an API that accepts PNG's results in a blank image.

@ggrossetie
Copy link
Member

I don't understand what that means. The return is an SVG and not a PNG. Renaming it to PNG doesn't help either. Internally it's not PNG data.

Sorry I wasn't clear, I was just posting a possible solution that I found.
Currently, Kroki only supports SVG for Mermaid but we could take inspiration from the Mermaid CLI and use the same technique to produce a PNG.

Another idea would be to use the browser to convert a SVG to a PNG using canvas: https://developer.mozilla.org/fr/docs/Web/API/Canvas_API

(sorry - don't know much about puppeteer if I'm missing something obvious here). And pushing the result into an API that accepts PNG's results in a blank image.

No worries, Puppeteer is a Node library that we use to run and interact with a headless Chrome browser.
To be clear I was not suggesting a workaround but a possible solution to implement this feature.

@ggrossetie ggrossetie added 📜 javascript Related to Javascript code 🍩 enhancement New feature or request labels Nov 27, 2020
@ggrossetie ggrossetie added the 👶 good first issue Good for newcomers label May 21, 2021
@derlin
Copy link
Contributor

derlin commented Oct 12, 2021

I am on it :)

derlin added a commit to derlin/kroki that referenced this issue Oct 12, 2021
derlin added a commit to derlin/kroki that referenced this issue Oct 12, 2021
derlin added a commit to derlin/kroki that referenced this issue Oct 13, 2021
derlin added a commit to derlin/kroki that referenced this issue Oct 13, 2021
derlin added a commit to derlin/kroki that referenced this issue Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👶 good first issue Good for newcomers 🍩 enhancement New feature or request 📜 javascript Related to Javascript code
Projects
None yet
Development

No branches or pull requests

3 participants