Skip to content

🔥 A native node.js bindings to the giflib, and provides useful APIs.

Notifications You must be signed in to change notification settings

kaelzhang/node-gifx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gifx

CURRENTLY STILL WORKING IN PROGRESS, DO NOT USE.

The GIF maker, reader and mangler, which is a native node.js bindings to the giflib.

install

$ npm i gifx

Usage

import Gifx from 'gifx'

const catBuffer = fs.readFileSync(filepathCat)
const dogBuffer = fs.readFileSync(filepathDog)

// Creates a new 300x200(square pixels) stage
new Gifx(300, 200)

.background('#ffffff')  // Sets the background color to '#ffffff',
                        // default to transparent)

.unit(500)              // Sets the unit time to 500 ms,
                        // i.e. each frame will last 500 ms
.layer()                      
  .start(0)             // Starts from the first frame.
                        // The index of a frame begins with 0.

  .duration(2)          // The duration is 1 second
  .add(catBuffer)       // Adds a cat
  .leave()              // Returns to the stage
.layer()
  .start(2)
  .end(5)               // Ends before (and NOT INCLUDES) the frame of
                        // index 5 (the fifth frame)
                        // which has the same effect with `.duration(3)`

  .add(dogBuffer, {     // Adds a dog with a x-axis offset of 150
    x: 150,
    y: 0
  })
  .leave()
.repeat(0)              // Repeat infinitely
.stream()               // Creates a readable stream and write to file.
.pipe(fs.createWriteStream('cat-and-dog.gif'))

new Gifx(width, height)

gif.unit(milliseconds = 1)

  • milliseconds number=1

Returns this

gif.layer()

Returns Layer

gif.repeat(repeat)

  • repeat number | boolean
    • 0 | true: infinite loop
    • 1 | false: no repeat
    • other number, 3 for example: plays 3 times

Returns gif

gif.stream()

Returns Stream.Readable

Layer

layer.start(start)

  • start number the

layer.duration(duration)

layer.end(end)

layer.leave()

Returns Gifx

About

🔥 A native node.js bindings to the giflib, and provides useful APIs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages