Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gifwrap

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gifwrap

A Jimp-compatible library for working with GIFs

  • 0.10.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
988K
decreased by-4.43%
Maintainers
1
Weekly downloads
 
Created

What is gifwrap?

The gifwrap npm package is a library for manipulating GIF images in Node.js. It provides a range of functionalities including creating, editing, and analyzing GIFs.

What are gifwrap's main functionalities?

Creating a GIF

This code demonstrates how to create a simple GIF with two frames using gifwrap. The frames are created with a specified delay, and the GIF is encoded and saved to a file.

const { Gif, GifFrame, GifCodec } = require('gifwrap');
const fs = require('fs');

const frame1 = new GifFrame(200, 200, { delayCentisecs: 50 });
const frame2 = new GifFrame(200, 200, { delayCentisecs: 50 });

const gif = new Gif({ repeat: 0, frames: [frame1, frame2] });

const codec = new GifCodec();
codec.encodeGif(gif).then((buffer) => {
  fs.writeFileSync('output.gif', buffer);
});

Reading a GIF

This code demonstrates how to read a GIF file and decode it using gifwrap. The number of frames in the GIF is then logged to the console.

const { GifCodec } = require('gifwrap');
const fs = require('fs');

const codec = new GifCodec();
const buffer = fs.readFileSync('input.gif');

codec.decodeGif(buffer).then((gif) => {
  console.log(gif.frames.length); // Number of frames in the GIF
});

Manipulating GIF Frames

This code demonstrates how to manipulate the frames of a GIF. It reads an existing GIF, modifies the first pixel of the first frame, and then saves the modified GIF.

const { Gif, GifFrame, GifCodec } = require('gifwrap');
const fs = require('fs');

const codec = new GifCodec();
const buffer = fs.readFileSync('input.gif');

codec.decodeGif(buffer).then((gif) => {
  const frame = gif.frames[0];
  frame.bitmap.data[0] = 255; // Modify the first pixel
  codec.encodeGif(gif).then((buffer) => {
    fs.writeFileSync('output.gif', buffer);
  });
});

Other packages similar to gifwrap

Keywords

FAQs

Package last updated on 17 Mar 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc