npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gifcreator

v0.1.3

Published

A Node.js GIF creation tool

Downloads

11

Readme

GifCreator

A simple and lightweight Node.js server-side GIF rendering tool. This tool utilizes FFmpeg to compose GIF images, offering easy operation and fast production, making it suitable for applications that require quick GIF animation generation.

Installation

Install this module via npm:

$ npm install gifcreator

About ffmpeg

Please note that this package relies on ffmpeg, so you need to install ffmpeg before using it.

The methods for installing FFmpeg on various Linux distributions differ slightly. Here are the installation steps for some common Linux distributions:

Usage Example

Creating a GIF Animation

The following example demonstrates how to use the GifCreator class to create a GIF animation with multiple frames and add images from a file path pattern.

const path = require('path');
const { createCanvas } = require('canvas');
const GifCreator = require('gifcreator');

function createGif() {
  const width = 500;
  const height = 500;
  const gifCreator = new GifCreator(width, height, true);
  const outputPath = path.resolve(__dirname, 'output.gif');
  gifCreator.setOutput(outputPath);
  gifCreator.setRepeat(true);
  gifCreator.setQuality(10);
  gifCreator.setFrameRate(18);
  gifCreator.on('success', () => {});

  for (let i = 0; i < 50; i++) {
    const canvas = createCanvas(width, height);
    const ctx = canvas.getContext('2d');

    ctx.fillStyle = 'blue';
    ctx.beginPath();
    ctx.arc(50 + (i % 50) * 8, 250, 30, 0, Math.PI * 2);
    ctx.fill();
    ctx.save();
    ctx.translate(250, 250);
    ctx.rotate((i * Math.PI) / 40);
    ctx.fillStyle = 'red';
    ctx.fillRect(-50, -50, 100, 100);
    ctx.restore();
    gifCreator.addFrame(canvas);
  }

  gifCreator.start();
}

Other uses

GifCreator also supports image input and video input, for example:

const imagePattern = path.resolve(__dirname, 'images', 'h%d.png');
gifCreator.addImage(imagePattern);
// or
const video = path.resolve(__dirname, 'video.mp4');
gifCreator.addVideo(video);

API and Documentation

Constructor

new GifCreator(width, height, verbose = false)

  • width: number - The width of the output GIF.
  • height: number - The height of the output GIF.
  • verbose: boolean (optional) - If true, enables verbose logging. Default is false.

Methods

setOutput(outputPath)

Sets the output path for the GIF.

  • outputPath: string - The file path where the GIF will be saved.

setRepeat(repeat)

Sets the repeat option for the GIF.

  • repeat: boolean - If true, the GIF will loop indefinitely. If false, it will not loop.

setDelay(delay)

Sets the delay between frames in the GIF.

  • delay: number - The delay in milliseconds.

setFrameRate(frameRate)

Sets the frame rate for the GIF.

  • frameRate: number - The frame rate in frames per second.

setTransparent(color)

Sets the transparent color for the GIF.

  • color: string - The color to be made transparent in the GIF.

setQuality(quality)

Sets the quality of the GIF.

  • quality: number - The quality level (1-31, where 1 is the best quality).

setFfmpegPath()

Sets the path for the FFmpeg executable.

addFrame(imageData)

Adds a frame to the GIF.

  • imageData: Buffer or Canvas - The image data for the frame.

addImage(imageFiles)

Adds images to the GIF.

  • imageFiles: string - The file path(s) of the images.

addVideo(videoPath)

Adds a video to the GIF.

  • videoPath: string - The file path of the video.

start()

Starts the FFmpeg process to create the GIF.

destroy()

Destroys the FFmpeg command and cleans up resources.

Events

success

Emitted when the FFmpeg process finishes successfully.

error

Emitted when there is an error during the FFmpeg process.

  • Parameters:
    • err: Error - The error object.

Contributing

GifCreator is an OPEN Open Source Project. This means that: Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit.

License

MIT LICENSE