How to use the gifwrap.GifUtil.quantizeDekker function in gifwrap

To help you get started, we’ve selected a few gifwrap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dadi / cdn / dadi / lib / handlers / image.js View on Github external
return Jimp.read(buffer).then(image => {
    let bitmap = new BitmapImage(image.bitmap)

    GifUtil.quantizeDekker(bitmap)

    let frame = new GifFrame(bitmap)

    let tmpGifFile = `${path.join(tmpDirectory, sha1(this.parsedUrl.original.path))}.gif`

    return GifUtil.write(tmpGifFile, [frame]).then(gif => {
      return fs.unlink(tmpGifFile).then(() => {
        return gif.buffer
      })
    })
  })
}
github GilbertGobbels / GAwesomeBot / Modules / Emoji / Emoji.js View on Github external
rawFrames.forEach(frames => {
		frames.forEach(frame => {
			frame.interlaced = false;
		});
	});

	for (let i = 0; i < rawFrames.length; i++) {
		if (i === 0) totalWidth += rawFrames[i][0].bitmap.width;
		else totalWidth += rawFrames[i][0].bitmap.width + 8;
	}

	const finalTotalFrames = await prepareEndFrames(totalWidth, totalHeight, rawFrames.slice(), totalFrames);
	finalTotalFrames.forEach(frame => {
		frame.interlaced = false;
	});
	GifUtil.quantizeDekker(finalTotalFrames);
	const gif = await codec.encodeGif(finalTotalFrames);
	let image = gif.buffer;
	if (gif.frames.length === 1) {
		const frame = gif.frames[0];
		const tempImage = new Jimp(0, 0);
		tempImage.bitmap = new BitmapImage(frame).bitmap;
		image = await new Promise((resolve, reject) => tempImage.getBuffer(MIME_PNG, (error, buffer) => error ? reject(error) : resolve(buffer)));
	}

	return {
		buffer: image,
		animated: gif.frames.length > 1,
	};
};

gifwrap

A Jimp-compatible library for working with GIFs

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis