gifski-command

Node.js module for gifski GIF encoder CLI

ISC License

Downloads
42
Stars
3
Committers
1

Gifski Command

Node.js module for gifski GIF encoder CLI

Getting started

To get started with this library, you need to install it and add it to your project.

Installation

# npm
npm install gifski-command --save

# yarn
yarn add gifski-command

Library Usage

API Reference available at https://pichillilorenzo.github.io/gifski-command/.

import * as path from 'path';
import {GifskiCommand} from 'gifski-command';
// or
const path = require('path');
const {GifskiCommand} = require('gifski-command');

const command = new GifskiCommand({
  output: path.join(__dirname, 'test', 'video.gif'),
  frames: [ path.join(__dirname, 'test', 'video.mp4.frame*.png') ],
  quality: 100
});
command.on('progress', progress => {
  console.log(progress);
});
const result = await command.run();

CLI Usage

  • <pattern> represents a glob pattern used to specify PNG frames used by gifski. Surround the glob pattern with quotes (example './test/**/*.png').
  • [options] are the same as the gifski CLI options.
Usage: gifski-command [options] <pattern>

Examples: 
  gifski-command -Q 100 -o './test/video.gif' './test/**/video.mp4.frame*.png'
  gifski-command -o - './test/**/video.mp4.frame*.png' > './test/video.gif'

Arguments:
  pattern                Glob pattern of PNG image files. Surround the glob pattern with quotes (example './test/**/*.png').

Options:
  -o, --output <a.gif>   Destination file to write to; "-" means stdout
  -r, --fps <num>        Frame rate of animation. This means the speed, as all frames are kept. [default: 20]
  --fast                 50% faster encoding, but 10% worse quality and larger file size
  --extra                50% slower encoding, but 1% better quality
  -Q, --quality <1-100>  Lower quality may give smaller file [default: 90]
  -W, --width <px>       Maximum width. By default anims are limited to about 800x600
  -H, --height <px>      Maximum height (stretches if the width is also set)
  --no-sort              Use files exactly in the order given, rather than sorted
  -q, --quiet            Do not display anything on standard output/console
  --repeat <num>         Number of times the animation is repeated (-1 none, 0 forever or <value> repetitions)
  -h, --help             display help for command

CLI Usage Example

The recommended way is to first export video as PNG frames. If you have ffmpeg installed, you can run in terminal:

ffmpeg -i ./test/video.mp4 ./test/video.mp4.frame%04d.png

and then make the GIF from the frames:

gifski-command -Q 100 -o './test/video.gif' './test/**/video.mp4.frame*.png'

This code snippet shows how to put into action gifski-command to convert video frames into a high quality GIF using the gifski encoder.

Contributors

Any contribution is appreciated. You can get started with the steps below:

  1. Fork this repository (learn how to do this here).

  2. Clone the forked repository.

  3. Make your changes and create a pull request (learn how to do this).

  4. I will attend to your pull request and provide some feedback.

License

This repository is licensed under the ISC License.