newtykip / canvas-gif

🖼️ Manipulate GIFs easily using node-canvas!
Other
21 stars 7 forks source link
canvas decoder encoder gif gm graphics graphicsmagick image nodejs npm web

canvas-gif

npm i canvas-gif

Package Size Version

What is canvas-gif?

canvas-gif is an NPM library that allows you to manipulate the frames of GIFs using node-canvas.

canvas-gif has been deprecated. I seldom use Node.js, let alone do I have a use for a package like this. If you are interested in taking over development, feel free to fork it and publish it yourself. My time with this library, however, has come to a halt.

How does it work?

It works by following these instructions:

  1. Read the input GIF as a Buffer (optional: coalesce the GIF if the option has been enabled and graphicsmagick is available)
  2. Decode the GIF into UInt8Array(s)
  3. For each frame in the GIF, create a canvas instance
  4. Transform the UInt8Array into canvas image data and put it onto the context
  5. Pass the context and other relevant information to the user defined editFrame function that will continue to manipulate the context.
  6. Add the newly edited frame's context to the encoder
  7. Output the encoder's data as a Buffer and return it

How can I make use of it?

You can download it using npm by running

npm i canvas-gif

And you can then proceed to use it in your code. For an example of how to do so, please check out the example folder.

Options

All of these options are optional! wow

Common Errors

There was an error during coalescing: Stream yields empty buffer. Reverting buffer to file buffer!

This error happens if the coalescing option is enabled but you are missing GraphicsMagick. Please install it from here and if the error persists feel free to report it as a problem and I'll try my best to help!

this project uses the opinionated queer license v1.1 - tl;dr see here :]

To-do