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

@canvacord/gif

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@canvacord/gif

GIF decoder/encoder for Canvacord

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-66.67%
Maintainers
2
Weekly downloads
 
Created
Source

@canvacord/gif

GIF Encoder and Decoder for Canvacord.

Installation

$ npm install --save @canvacord/gif

// or
$ yarn add @canvacord/gif

Examples

Decoding GIF

// es6
import { Decoder } from '@canvacord/gif';
import { readFileSync, createWriteStream } from 'fs';

// cjs
const { Decoder } = require('@canvacord/gif');
const { readFileSync, createWriteStream } = require('fs');

const source = readFileSync('./img.gif');
const decoder = new Decoder(source);
const rawFrames = decoder.decode();

// log raw frames data
console.log(rawFrames);

// get png image of each frame
const pngFrames = decoder.toPNG(rawFrames);

for (let i = 0; i < pngFrames.length; i++) {
    const frame = pngFrames[i];
    frame.pipe(createWriteStream(`./frame_${i}.png`));
}

Encoding raw frame to GIF

// es6
import { Decoder, Encoder } from '@canvacord/gif';
import { readFileSync, createWriteStream } from 'fs';

// cjs
const { Decoder, Encoder } = require('@canvacord/gif');
const { readFileSync, createWriteStream } = require('fs');

const source = readFileSync('./img.gif');
const decoder = new Decoder(source);
const rawFrames = decoder.decode();

// encode each frames into gif
for (let i = 0; i < rawFrames.length; i++) {
    const frame = new Encoder(rawFrames[i]).encode();
    frame.pipe(createWriteStream(`./frame_${i}.gif`));
}

Keywords

FAQs

Package last updated on 04 Jun 2021

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