Generated gif is very blurry no matter the font size
Closed this issue · 3 comments
Describe the bug
When I generate a gif it is very blurry. This is the case no matter how much I increase the font size.
To Reproduce
Steps to reproduce the behavior:
- Run
cargo install --git https://github.com/asciinema/agg
- Download this asciinema file: https://asciinema.org/a/620647
- Run
agg 620649.cast output.gif
- Observe blurriness:
Expected behavior
I expected a gif to be generated with non-blurry text, similar to the demonstration examples in the README.
Versions:
- OS: Arch Linux
- agg: 4ef524c
Additional context
Output of -v
:
[INFO agg] terminal size: 59x18
[INFO agg] selected font families: ["DejaVu Sans Mono", "DejaVu Sans"]
[INFO agg] selected theme: dracula
[INFO agg] gif dimensions: 514x372
93 / 93 [=================================================================================================================================================] 100.00 % 203.99/s
[INFO agg] rendering finished in 0.45609793s
I also tried this on macOS with the same result.
agg's font renderer uses anti-aliasing, which makes text blurry at lower resolutions. Your output shows 514x372 image size for the default font size (14px).
Have you tried doubling the font size?
Here's what I did:
agg -v --font-size 28 https://asciinema.org/a/620647 out3.gif
[INFO agg] terminal size: 59x18
[INFO agg] selected font families: ["JetBrains Mono", "DejaVu Sans Mono", "Liberation Mono", "DejaVu Sans"]
[INFO agg] selected theme: dracula
[INFO agg] gif dimensions: 1025x745
93 / 93 [================================================================================] 100.00 % 70.50/s
[INFO agg] rendering finished in 1.3192732s
Resulting GIF:
I agree it's not super-sharp at this font-size though.
The example in the README uses JetBrains Mono font, and, if I remember correctly, was generated with --font-size 28
.
There are 2 frame renderers in agg: fontdue
(default), and resvg
.
I also tested with alternative resvg
renderer, which renders each frame by first generating SVG and then rasterizing it:
agg -v --font-size 28 --renderer resvg https://asciinema.org/a/620647 out3.gif
The result is similar though (resvg renderer doesn't handle special symbols/icons well, ignore that):
I believe what you observe in the README example is a result of bigger terminal size in the recording (wider, taller) combined with 28px font size. That GIF file is wider than the width of the README display (if you displayed it 1:1), so the browser scales it down to fit the container, making the font look sharper.
I think you're right that the sharpness I'm seeking is found with larger font/higher resolution along with the image being restricted to a smaller window. Thanks!