Socket
Socket
Sign inDemoInstall

canvas-gif

Package Overview
Dependencies
77
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    canvas-gif

Manipulate GIFs easily using node-canvas!


Version published
Weekly downloads
248
increased by85.07%
Maintainers
1
Install size
163 MB
Created
Weekly downloads
 

Readme

Source

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.

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

  • coalesce - Whether the GIF should be coalesced by GraphicsMagick before being processed by the engine. Requires GraphicsMagick to be installed - if it is not and the option is true and error will be thrown and the code will continue with the original file buffer. Defaults to false
  • delay - The amount of delay between each frame in ms. Defaults to 0
  • repeat - How many times the GIF should repeat. If the value is 0, it will repeat forever. Defaults to 0
  • algorithm - The algorithm the encoder should use. Can be one of neuquant and octree. Defaults to neuquant
  • optimiser - Whether the encoder should use its in-built optimiser. Defaults to false
  • fps - The amount of frames to render per second. Defaults to 60
  • quality - The quality of the GIF. A value between 1-100. The higher the number, the better quality the GIF will be. Defaults to 100

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!

See the code's license here.

To-do

  • Return emitter for easy event handling

Keywords

FAQs

Last updated on 08 Apr 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc