All Projects → asciinema → Asciicast2gif

asciinema / Asciicast2gif

Licence: mit
Generate GIF animations from asciicasts (asciinema recordings)

Labels

Projects that are alternatives of or similar to Asciicast2gif

Libvips
A fast image processing library with low memory needs.
Stars: ✭ 6,094 (+597.25%)
Mutual labels:  gif
Flyimg
Dockerized PHP7 application runs as a Microservice to resize and crop images on the fly. Get optimised images with MozJPEG, WebP or PNG using ImageMagick. Includes face detection, cropping, face blurring, image rotation and many other options. Abstract storage based on FlySystem in order to store images on any provider (local, AWS S3...).
Stars: ✭ 762 (-12.81%)
Mutual labels:  gif
Gifhub
📈 Create GIFs from user's GitHub activity graph
Stars: ✭ 17 (-98.05%)
Mutual labels:  gif
Allsketchs
Processing sketches, in which I have worked in the last years; images, videos, prototypes, experiments, tools, works, concepts... Everything is unfinished, some may not work, When I had no ideas, I would open one to see what it was...
Stars: ✭ 666 (-23.8%)
Mutual labels:  gif
Nuxt Optimized Images
🌅🚀 Automatically optimizes images used in Nuxt.js projects (JPEG, PNG, SVG, WebP and GIF).
Stars: ✭ 717 (-17.96%)
Mutual labels:  gif
Image Optimizer
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.
Stars: ✭ 785 (-10.18%)
Mutual labels:  gif
Gifski
🌈 Convert videos to high-quality GIFs on your Mac
Stars: ✭ 5,691 (+551.14%)
Mutual labels:  gif
Giflossy
Merged into Gifsicle!
Stars: ✭ 937 (+7.21%)
Mutual labels:  gif
Gifcapture
🏇 Gif capture app for macOS
Stars: ✭ 754 (-13.73%)
Mutual labels:  gif
Sdwebimageflplugin
A SDWebImage plugin to support GIF using FLAnimatedImage and category
Stars: ✭ 16 (-98.17%)
Mutual labels:  gif
Gifify
😻 Convert any video file to an optimized animated GIF.
Stars: ✭ 5,792 (+562.7%)
Mutual labels:  gif
Moments
A quick GIF replay recorder for Unity
Stars: ✭ 713 (-18.42%)
Mutual labels:  gif
Scrimage
Java, Scala and Kotlin image processing library
Stars: ✭ 792 (-9.38%)
Mutual labels:  gif
Quick Media
media(audio/image/qrcode/markdown/html/svg) support web service (多媒体编辑服务, 酷炫二维码, 音频, 图片, svg, markdown, html渲染服务支持)
Stars: ✭ 612 (-29.98%)
Mutual labels:  gif
X11 Recorder
xrec helps you capture any area of your screen either as a screenshot or record a gif file.
Stars: ✭ 17 (-98.05%)
Mutual labels:  gif
Optimizt
CLI image optimization tool
Stars: ✭ 594 (-32.04%)
Mutual labels:  gif
Pixterm
Draw images in your ANSI terminal with true color
Stars: ✭ 782 (-10.53%)
Mutual labels:  gif
Sdwebimageswiftui
SwiftUI Image loading and Animation framework powered by SDWebImage
Stars: ✭ 844 (-3.43%)
Mutual labels:  gif
Is Animated
Checks if image is animated 🎞
Stars: ✭ 17 (-98.05%)
Mutual labels:  gif
Gifcurry
😎 The open-source, Haskell-built video editor for GIF makers.
Stars: ✭ 830 (-5.03%)
Mutual labels:  gif

asciicast2gif

asciicast2gif is a tool for generating GIF animations from asciicast files recorded by asciinema.

How it works

Here's how the asciicast->GIF conversion is implemented.

asciicast2gif shell script parses command line arguments and executes Node.js script (main.js). main.js loads asciicast (either from remote URL or local filesystem), generates text representation of the screen for each frame using asciinema-player's virtual terminal emulator, and sends it to PhantomJS-based renderer script (renderer.js), which saves PNG screenshots to a temporary directory. Finally, main.js calls ImageMagick's convert on these PNG images to construct GIF animation, also piping it to gifsicle to get the final, optimized GIF file.

Note, asciicast2gif doesn't capture screenshots at a fixed frame-rate (e.g. 30 FPS) like alternative tools. Instead, it generates PNG files for each screen update, and specifies delay for every image individually (convert -delay <delay-a> 0.png -delay <delay-b> 1.png -delay <delay-c> 2.png ...). When the screen is idle there're no screenshots generated. This saves disk space and makes it less work for both convert and gifsicle, while resulting in smaller GIF file.

Installation

You can install asciicast2gif with npm, use it via Docker image, or build it from source.

npm package

To install asciicast2gif using npm run:

npm install --global asciicast2gif

Following runtime dependencies need to be also installed:

Docker image

You can use asciicast2gif through official asciicast2gif Docker image (automated build on Docker Hub from this repository).

Pull the image:

docker pull asciinema/asciicast2gif

Use it like this:

docker run --rm -v $PWD:/data asciinema/asciicast2gif [options and arguments...]

You need to mount some local directory at /data so input and output files can be accessed by the container. Mounting current working directory ($PWD) makes most sense in majority of cases.

For example, generating GIF from local file, with double speed and Solarized theme:

docker run --rm -v $PWD:/data asciinema/asciicast2gif -s 2 -t solarized-dark demo.json demo.gif

Running the above, long command can get old very quickly. Creating a shell alias may be a good idea:

alias asciicast2gif='docker run --rm -v $PWD:/data asciinema/asciicast2gif'

Look at general usage instructions below for all command line arguments, options etc.

Note: if you want to override gifsicle options (via GIFSICLE_OPTS env var) when using Docker image you need to pass it via Docker's -e option.

Building from source

Clone the repository:

git clone --recursive https://github.com/asciinema/asciicast2gif.git
cd asciicast2gif

All further commands are assumed to be called from within the checked out directory.

Install build time dependencies

Both Node.js script (main.js) and page script used by renderer's HTML page (page/page.js) need to be build from ClojureScript source code.

You need Java 8 JDK and Leiningen.

Install runtime dependencies

Following runtime dependencies need to be installed:

Install Node.js wrapper for PhantomJS:

npm install

If you don't have PhantomJS available in $PATH at this point it will be automatically downloaded during phantomjs-prebuilt package installation.

Build

To build the scripts run:

lein cljsbuild once main && lein cljsbuild once page 

Usage

asciicast2gif [-t theme] [-s speed] [-S scale] [-w cols] [-h rows] <input-json-path-or-url> <output-gif-path>

Following options are supported:

-t <theme>        color theme, one of: asciinema, tango, solarized-dark, solarized-light, monokai (default: asciinema)
-s <speed>        animation speed (default: 1)
-S <scale>        image scale / pixel density (default: 2)
-w <columns>      clip terminal to specified number of columns (width)
-h <rows>         clip terminal to specified number of rows (height)

Example of generating GIF from asciicast URL, with default options (normal speed, double pixel density, asciinema theme):

asciicast2gif https://asciinema.org/a/118274.json demo.gif

example gif 1

Example of generating GIF from local asciicast file, with Solarized Dark theme, double speed (-s 2), single pixel density (-S 1):

asciicast2gif -t solarized-dark -s 2 -S 1 118274.json demo.gif

example gif 2

Setting custom gifsicle options

You can override default options passed to giflossy/gifsicle by setting GIFSICLE_OPTS environment variable.

Default options when giflossy is installed are:

-k 64 -O2 -Okeep-empty --lossy=80

Default options when gifsicle is installed are:

-k 64 -O2 -Okeep-empty

For example to generate 16 color gif, with level 3 optimizations, set it like this:

GIFSICLE_OPTS="-k 16 -O3"

Debugging

You can set DEBUG=1 environment variable to make the output of the conversion process more verbose.

Tweaking conversion process

You can pass extra arguments to Node.js script invocation via NODE_OPTS environment variable.

Limiting node process memory usage

Limit Node's heap size to 512 MB:

NODE_OPTS="--max-old-space-size=512" asciicast2gif ...

Alternatives

There are following alternative tools solving this problem:

License

Copyright © 2017 Marcin Kulik.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].