Skip to main content

Unofficial binary wheels for asciinema-gif-generator

Project description

agg - asciinema gif generator

agg is a command-line tool for generating animated GIF files from asciicast v2 files produced by asciinema terminal recorder.

It uses Kornel Lesiński's excellent gifski library to produce optimized, high quality GIF output with accurate frame timing.

agg is a successor to asciicast2gif.

Demo

Building

Building from source requires Rust compiler (1.56.0 or later) and Cargo package manager. You can install both with rustup.

To download source code, build agg binary and install it in $HOME/.cargo/bin run:

cargo install --git https://github.com/asciinema/agg

You need to ensure $HOME/.cargo/bin is in your shell's $PATH.

Alternatively, you can manually download source code and build agg binary with:

git clone https://github.com/asciinema/agg
cd agg
cargo build --release

This produces an executable file in release mode (--release) at target/release/agg. There are no other build artifacts so you can copy the binary to a directory in your $PATH.

Building via Docker

Alternatively, if you have Docker, Podman or another Docker-compatible tool installed you can use it to build agg container image. This doesn't require Rust toolchain installed on your machine.

Build the image with the following command:

docker build -t agg .

Then run agg like this:

docker run --rm -it -u $(id -u):$(id -g) -v $PWD:/data agg demo.cast demo.gif

If you use Podman in root-less mode:

podman run --rm -it -v $PWD:/data agg demo.cast demo.gif

Usage

Basic usage:

agg demo.cast demo.gif

The above command renders a GIF file with default theme (dracula), font size 14px.

You can also provide an asciinema.org URL as the first argument:

agg https://asciinema.org/a/569727 starwars.gif

Additional options are available for customization. For example, the following command selects Monokai theme, larger font size, 2x playback speed:

agg --theme monokai --font-size 20 --speed 2 demo.cast demo.gif

Run agg -h to see all available options. Current options are:

    --cols <COLS>
        Override terminal width (number of columns)

    --font-dir <FONT_DIR>
        Use additional font directory

    --font-family <FONT_FAMILY>
        Specify font family [default: "JetBrains Mono,Fira Code,SF Mono,Menlo,Consolas,DejaVu
        Sans Mono,Liberation Mono"]

    --font-size <FONT_SIZE>
        Specify font size (in pixels) [default: 14]

    --fps-cap <FPS_CAP>
        Set FPS cap [default: 30]

-h, --help
        Print help information

    --idle-time-limit <IDLE_TIME_LIMIT>
        Limit idle time to max number of seconds [default: 5]

    --line-height <LINE_HEIGHT>
        Specify line height [default: 1.4]

    --no-loop
        Disable animation loop

    --renderer <RENDERER>
        Select frame rendering backend [default: fontdue] [possible values: fontdue, resvg]

    --rows <ROWS>
        Override terminal height (number of rows)

    --speed <SPEED>
        Adjust playback speed [default: 1]

    --theme <THEME>
        Select color theme [possible values: asciinema, dracula, monokai, solarized-dark,
        solarized-light, custom]

-v, --verbose
        Enable verbose logging

-V, --version
        Print version information

Fonts

By default agg uses common monospaced font for a given platform, that can be found on its default font family list. The list includes DejaVu Sans Mono and Liberation Mono (found on most Linux distros), SF Mono and Menlo (found on macOS), Consolas (found on Windows), with addition of my personal favourites like JetBrains Mono and Fira Code. The fonts are not included in agg and must be present on the system. To see the default value run agg --help and look for --font-family. In addition there's implicit fallback to DejaVu Sans (not Mono) which helps with rendering symbols like ⣽ or ✔ amongst others.

If you want to use another font family then pass a comma-separated list like this:

agg --font-family "Source Code Pro,Fira Code" demo.cast demo.gif

As long as the fonts you want to use are installed in one of standard system locations (e.g. /usr/share/fonts or ~/.local/share/fonts on Linux) agg will find them. You can also use --font-dir=/path/to/fonts option to include extra fonts. --font-dir can be specified multiple times.

To verify agg picks up your font run it with -v (verbose) flag:

agg -v --font-family "Source Code Pro,Fira Code" demo.cast demo.gif

It should print something similar to:

[INFO agg] selected font families: ["Source Code Pro", "Fira Code", "DejaVu Sans", "Noto Emoji"]

This list may also include implicit addition of DejaVu Sans fallback (mentioned earlier), as well as Noto Emoji (see section below).

Here's how to use Nerd Fonts with agg:

  1. Download one of the patched font sets from https://github.com/ryanoasis/nerd-fonts/releases/latest , e.g. JetBrainsMono.zip
  2. Unzip them into ~/.local/share/fonts (on Linux) or install with system font manager (macOS, Windows)
  3. Specify font family like this:
agg --font-family "JetBrainsMono Nerd Font Mono" demo.cast demo.gif

Emoji

Currently agg supports only monochrome emojis via Noto Emoji font.

Install Noto Emoji font on your system or, point agg to a folder containing NotoEmoji-*.ttf files with --font-dir.

Note that Noto Color Emoji font is not supported. Be aware that some distros ship this color font by name like "noto-fonts-emoji". This is not what you need.

Color themes

There are several built-in color themes you can use with --theme option:

  • asciinema
  • dracula (default)
  • monokai
  • solarized-dark
  • solarized-light

If your asciicast file includes theme definition then it's used automatically unless --theme option is explicitly specified.

A custom, ad-hoc theme can be used with --theme option by passing a series of comma-separated hex triplets defining terminal background color, default text color and a color palette:

--theme bbbbbb,ffffff,000000,111111,222222,333333,444444,555555,666666,777777

The above sets terminal background color to bbbbbb, default text color to ffffff, and uses remaining 8 colors as SGR color palette.

Additional bright color variants can be specified by adding 8 more hex triplets at the end. For example, the equivalent of the built-in Monokai theme is:

--theme 272822,f8f8f2,272822,f92672,a6e22e,f4bf75,66d9ef,ae81ff,a1efe4,f8f8f2,75715e,f92672,a6e22e,f4bf75,66d9ef,ae81ff,a1efe4,f9f8f5

Additional GIF optimization

GIF encoder used by agg, gifski, produces great looking GIF files, although this often comes at a cost - file size.

gifsicle can be used to shrink the produced GIF file:

gifsicle --lossy=80 -k 128 -O2 -Okeep-empty demo.gif -o demo-opt.gif

Every recording is different so you may need to tweak the lossiness level (--lossy), number of colors (-k) and other options to suit your needs.

Consulting

I offer consulting services for asciinema project. See https://asciinema.org/consulting for more information.

License

© 2022 Marcin Kulik.

All code is licensed under the Apache License, Version 2.0. See LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asciinema_gif_generator-1.4.3.tar.gz (15.7 MB view details)

Uploaded Source

Built Distributions

asciinema_gif_generator-1.4.3-py3-none-win_amd64.whl (3.6 MB view details)

Uploaded Python 3 Windows x86-64

asciinema_gif_generator-1.4.3-py3-none-win32.whl (3.4 MB view details)

Uploaded Python 3 Windows x86

asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_x86_64.whl (4.4 MB view details)

Uploaded Python 3 musllinux: musl 1.2+ x86-64

asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_i686.whl (4.4 MB view details)

Uploaded Python 3 musllinux: musl 1.2+ i686

asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_armv7l.whl (4.2 MB view details)

Uploaded Python 3 musllinux: musl 1.2+ ARMv7l

asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_aarch64.whl (4.3 MB view details)

Uploaded Python 3 musllinux: musl 1.2+ ARM64

asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ x86-64

asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (4.6 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ i686

asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (4.1 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.3 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

asciinema_gif_generator-1.4.3-py3-none-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded Python 3 macOS 11.0+ ARM64

asciinema_gif_generator-1.4.3-py3-none-macosx_10_12_x86_64.whl (4.0 MB view details)

Uploaded Python 3 macOS 10.12+ x86-64

File details

Details for the file asciinema_gif_generator-1.4.3.tar.gz.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3.tar.gz
Algorithm Hash digest
SHA256 facace2adae895ffb8ed0abe97f8a3542a8ea7d15d5e1f39339520355e50219f
MD5 f3f2f1246057bd0802144603a4fea00d
BLAKE2b-256 f80c1b5afe84317a6ebbb803d2101ab48a8a6a6b35d9767ce361f1eefb7ef218

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9c1fb8b785f77f09b73e4ea9b2cbe319597bb380d2851f25f8e7639a39392b74
MD5 5421dda96764eccaa65a177ce2925fd8
BLAKE2b-256 6e911d75e9cac79c8e3a7158f18168f07b1efd6e27bb2d8a1b2fa5e8fa6bee16

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-win32.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-win32.whl
Algorithm Hash digest
SHA256 5a7bebcb756c6eb8d88a1f3a0a72bd0828e689797da6175630d34702c84371bb
MD5 5e651531aa19f3f6b8fbf566abee369d
BLAKE2b-256 1a4d91ed68b00bc340acd61119be88d337b9bd9da1e25941234deedea54c6542

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0929aad9dbf8da4281dd96df75e9bfcc4d4d12f8492d9f5c416dfa6ec3663cce
MD5 ec11bc267569cc07cccfeeb8676f35d6
BLAKE2b-256 0f3fd2358a4c02cd2c6a6c536f128beaaeb84815937cefd41f8a5f45178f902c

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 c400e9e7ffb6516c1d8d5e5f2eba747b10ddbdf1a8dc081edacc1c73821bc88e
MD5 b7554c5e6b30e34953380444389b36b2
BLAKE2b-256 180da22607bde05ec3b1adbad6e9966287b97e84238c0164d93fb11a3be6a697

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 f83c377048f5ce27da18ed3389c381a0ad316c5e8ec2ab336ae84348e5561fce
MD5 8b98c52cd961edb50474c4c860689635
BLAKE2b-256 80d5110522ec2afeaf4ed2d0d942955c85a43cc368e82f33cb8882b4df09d1af

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 848d51c64f9d8cbfc63f9ce82080bca748f00fd906b16018f883207bb7a5f975
MD5 191d4f297a2badfb08a8d7dd9a698492
BLAKE2b-256 9eaa559e472d082d8bb4285a63bffa9aeebffdf699de27f291507aca40681435

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d020df56d7b1ccf4daab176953857899f63435ef218b0ecd095d81aa7f402b16
MD5 3806ecf06cab581aed4a1fdd48368916
BLAKE2b-256 2da33e9698c2575969dd8fb8ca199d143ff33d879567373459be518c7d9f7cbd

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 30ba7219bc406c409266aa2b0a9ed4b94aeab15eda46ec4d49f295c48caa74e2
MD5 f79e2eff8dfdb27c06a13b580a39907f
BLAKE2b-256 b9953084a45e13c00f7fb1b947cd7eaaa5a7c0704c7587c153f7c2730db40c72

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 356d2c91a101b10b7865c9e64017fbf7a8b37cac8ed5b9d2d413cdebaf4f9b2f
MD5 0048d40e27c13c9d6aec7afa79e5283b
BLAKE2b-256 e7bbaacce0f75a57a8fad9060227ddb4ea5b12bf2a9867ae8daa609ad0380ac5

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 749e2d5af4f2cc34b535403d57b97d27ae0883cbac13d5c2967a45a6a771719b
MD5 a9de13ab742df92c312f467fd8f2b669
BLAKE2b-256 478d533a804c4a7aec238841c823bfe9db74b9ab54313ac377e32ed65fcc9477

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 750269db7955e23dbd62a4aa187e53560d65038cb17887402417818fa1e3c2c5
MD5 fc9db224c24e980fa578c0e549d846ca
BLAKE2b-256 ffa5fa65d48c860430ed33d2a8c347e7ff6b0bccdc95b2cc1f9f99d3ae5939db

See more details on using hashes here.

File details

Details for the file asciinema_gif_generator-1.4.3-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for asciinema_gif_generator-1.4.3-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c2bf2c634de490e6b8a158b928f26c010ebaffb636688d57f73d553a19ccd6ad
MD5 8d88301f827c697d95052ff08cd9c236
BLAKE2b-256 cd775f73a8e9bc6fc4307522ec896685c88a67c8f2bb3bb018b7fb0e9d9b9915

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page