charmbracelet / freeze

Generate images of code and terminal output 📸
MIT License
3.24k stars 55 forks source link

"Dynamic output" generates a giant image #61

Closed Su3h7aM closed 6 months ago

Su3h7aM commented 6 months ago

Describe the bug Commands that have a "dynamic output" generate a giant image containing all the "frames".

To Reproduce In my case, I tried to generate an image with hyperfine, but the output was an image measuring 240273 x 668px.

Expected behavior Generate an image with the last command output.

Screenshots I'm not going to attach the generating image because it's too big, and it's impossible to see anything without a lot of zoom.

Desktop

Su3h7aM commented 6 months ago

It also happens that system monitors like htop, glances, btop generate unusable images.

btop output: btop glances output: glances htop output:

ERROR  Bad SVG
XML syntax error on line 13: illegal character code U+0008

I was unsure whether to create a new issue or add it here. If you prefer, I can create another issue, so that it is more organized.

maaslalani commented 6 months ago

For btop, the output can likely be fixed by allowing people to resize the terminal by exposing --row/--col attributes and setting them dynamically here:

https://github.com/charmbracelet/freeze/blob/main/pty.go#L23-L24

maaslalani commented 6 months ago

I see that hyperfine is a TUI which can output lots of output while it is benchmarking the tool. This is likely all getting captured within the input (We can fix / limit that on our end).

However, for hyperfine I would highly recommend using tmux capture-pane with the result so that you can capture the final output. See the Screenshot TUIs section in the README: https://github.com/charmbracelet/freeze?tab=readme-ov-file#screenshot-tuis

We will make this better in the future to solve for these use cases as well!

Su3h7aM commented 6 months ago

For btop, the output can likely be fixed by allowing people to resize the terminal by exposing --row/--col attributes and setting them dynamically here:

https://github.com/charmbracelet/freeze/blob/main/pty.go#L23-L24

Cool, that would be a great addition. It may end up being useful on other occasions.

Su3h7aM commented 6 months ago

I see that hyperfine is a TUI which can output lots of output while it is benchmarking the tool. This is likely all getting captured within the input (We can fix / limit that on our end).

However, for hyperfine I would highly recommend using tmux capture-pane with the result so that you can capture the final output. See the Screenshot TUIs section in the README: https://github.com/charmbracelet/freeze?tab=readme-ov-file#screenshot-tuis

We will make this better in the future to solve for these use cases as well!

Sorry, my lack of attention. But it would really be interesting to be able to use it natively with TUI apps.

maaslalani commented 6 months ago

@Su3h7aM You may also want to check out https://github.com/charmbracelet/vhs for recording TUIs which will provide the full animation of Hyperfine as well (and it can also produce screenshots).