Export as PNG or JPEG or any image
Roh-codeur opened this issue · 5 comments
Hi
this is truly an awesome package.
qq: is there a way to export the generated output to image please? I want to post it to Slack using code, unfortunately, as Text it loses all highlights and formatting.
thanks
Roh
Hi @Roh-codeur
Thanks! I am glad it is being useful :)
Do you mean generate a PNG from the terminal output?
@ronisbr : hey mate, thanks for coming back. yeah indeed, I have a beautiful output generated using PrettyTables.jl. I want to be able to export this output to png, so I can send this to Slack.
ta!
In this case, we need some external tool that renders the escape sequences into a PNG. I did this in the past using a combination of aha
, wkhtmltopdf
, and convert
. However, it was so complicated that the best way is just to take a screenshot of your terminal.
I am closing this bug since this feature should be handled outside PrettyTables.jl.
Hi @Roh-codeur !
I just found and AMAZING tool that will help you to do this. It is called AnsiToImg.
You can obtain the SVG of the PrettyTables.jl output by:
str = pretty_table(
String,
[0:10 0:2:20 0:4:40];
color = true,
tf = tf_unicode_rounded,
highlighters = hl_geq(5)
)
write("tmp", str)
run(`ansitoimg --title "Generated by AnsiToImg" tmp output.svg`)
run(`rm tmp`)
leading to: