Suppose the CLI application my_bin
produces an output in terminal which consists of colored text, Unicode symbols and emojis.
How can I convert the output to a svg or an image on Ubuntu?
For example, curl "v2.wttr.in/Berlin"
output is like this in the terminal:
How can I convert it to an image file (e.g. vectored image file, png, svg, etc)?
Update:
I need a solution that doesn't actually need rendering the output of the command in a terminal window. So it should work in background without having to utilize X or Wayland to capture its view.
Tried
curl "v2.wttr.in/Berlin" | pbmtext | pnmtopng > out.png
This does not render colors or emojisTried
pango-view --font='mono' -qo out.png <(curl v2.wttr.in/Berlin)
It renders emojis but does not render terminal escape codes for colors.
lpr
orenscript
. I'm having trouble getting it to work though so a possible workaround would be to usexdotool
or similar to open the file and trigger a screenshot. – terdon Jan 31 '22 at 13:15import
tool from imagemagick needs a rendered window. I want a solution that doesn't need the actual output to be rendered anywhere...likemy_app | convert_to_image | ...
– Zeta.Investigator Jan 31 '22 at 13:25:@-
option but it does not work here (it doesn't render the colors):curl 'https://v2.wttr.in/Berlin' | convert label:@- out.png
– Zeta.Investigator Jan 31 '22 at 13:39.png
functionality shown in the answer below. Thattextimg
is looks very nice though. – Zeta.Investigator Feb 26 '23 at 09:28