Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
@skyra/gifenc
Advanced tools
gifencoder
, this module wouldn't have existed without its author.You can use the following command to install this package, or replace npm install
with your package manager of choice.
npm install @skyra/gifenc
@skyra/gifenc
is very close to a drop-in replacement forgifencoder
. There are only 2 differences to account for. First of all, the encoder class is namedGifEncoder
and notGIFEncoder
, and secondly, the metadata methods are chainable.
const { GifEncoder } = require('@skyra/gifenc');
const { createWriteStream } = require('node:fs');
const encoder = new GifEncoder(400, 400);
// Set the repeat mode: 0 for repeat, -1 for no-repeat:
.setRepeat(0)
// Set the frame delay in milliseconds:
.setDelay(500)
// Set the image quality, 10 is default:
.setQuality(10);
// Create a read stream and pipe it into a file write stream:
encoder.createReadStream()
.pipe(createWriteStream('my-file.gif'));
encoder.start();
// `getFrames` enumerates over frames
for (const frame of getFrames()) {
encoder.addFrame(frame);
}
encoder.finish();
We can use streamConsumers.buffer()
from Node.js to convert the stream into a buffer starting with Node.js v16.7.0, if you're using an older version, consider making a function using stream's async iterator (Node.js v10+) or use a package.
const { GifEncoder } = require('@skyra/gifenc');
const { buffer } = require('node:stream/consumers');
const encoder = new GifEncoder(400, 400);
const stream = encoder.createReadStream();
encoder.setRepeat(0).setDelay(500).setQuality(10).start();
// `getFrames` enumerates over frames
for (const frame of getFrames()) {
encoder.addFrame(frame);
}
encoder.finish();
const result = await buffer(stream);
const { GifEncoder } = require('@skyra/gifenc');
const { Canvas } = require('canvas-constructor/skia');
// const { Canvas } = require('canvas-constructor/cairo');
const canvas = new Canvas(400, 400);
const encoder = new GifEncoder(400, 400);
const stream = encoder.createReadStream();
encoder.setRepeat(0).setDelay(500).setQuality(10).start();
const colors = ['#98DDCA', '#D5ECC2', '#FFD3B4', '#FFAAA7'];
for (const color of colors) {
canvas.setColor(color).printRectangle(0, 0, 400, 400);
encoder.addFrame(canvas);
}
// ...
@skyra/gifenc
supports ESM out of the box. To import the GifEncoder
class, you use the following statement:
import { GifEncoder } from '@skyra/gifenc';
Skyra Project is open source and always will be, even if we don't get donations. That said, we know there are amazing people who may still want to donate just to show their appreciation. Thanks you very much in advance!
We accept donations through Patreon, BitCoin, Ethereum, and Litecoin. You can use the buttons below to donate through your method of choice.
Donate With | QR | Address |
---|---|---|
Patreon | Click Here | |
PayPal | Click Here | |
BitCoin | 3JNzCHMTFtxYFWBnVtDM9Tt34zFbKvdwco | |
Ethereum | 0xcB5EDB76Bc9E389514F905D9680589004C00190c | |
Litecoin | MNVT1keYGMfGp7vWmcYjCS8ntU8LNvjnqM |
Thanks goes to these wonderful people (emoji key):
Antonio Román 💻 🤔 🚇 | Jeroen Claassens 🚇 🚧 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
A very fast server-side animated GIF generation for Node.js
The npm package @skyra/gifenc receives a total of 6,413 weekly downloads. As such, @skyra/gifenc popularity was classified as popular.
We found that @skyra/gifenc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.