How to use the gifwrap.BitmapImage 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 GilbertGobbels / GAwesomeBot / Modules / Emoji / Emoji.js View on Github external
frames.map(async frame => {
				const image = new Jimp(frame.bitmap.width, frame.bitmap.height);
				const bImage = new BitmapImage(frame);
				image.bitmap = bImage.bitmap;
				image.resize(128, AUTO);
				return new GifFrame(bImage);
			});
			const { buffer } = await codec.encodeGif((await Promise.all(frames)).map(frame => {
github tt-bot-dev / tt.bot / lib / e2p / prepareFrames.js View on Github external
frames.map(g => new Promise((rs, rj) => new Jimp(g.bitmap.width, g.bitmap.height, (e, image) => {
        if (e) rj(e);
        let bImg = new GifWrap.BitmapImage(g);
        image.bitmap = bImg.bitmap;
        let w = result.type == "unicodeEmote" ? 72 : 128;
        image.resize(w,AUTO);
        rs(new GifWrap.GifFrame(bImg));
    })
    ));
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 / PrepareFrames.js View on Github external
frames.map(async frame => {
		const image = new Jimp(frame.bitmap.width, frame.bitmap.height);
		const bImage = new BitmapImage(frame);
		image.bitmap = bImage.bitmap;
		image.resize(result.type === "unicode" ? 72 : 128, AUTO);
		return new GifFrame(bImage);
	});
	return {
github GilbertGobbels / GAwesomeBot / Modules / EmojiGIF.js View on Github external
const img = new Jimp(frame.bitmap.width, frame.bitmap.height, (error, image) => {
				if (error) return reject(error);
				let bImage = new BitmapImage(frame);
				image.bitmap = bImage.bitmap;
				image.resize(128, AUTO);
				resolve(new GifFrame(bImage));
			});
		}));
github GilbertGobbels / GAwesomeBot / Modules / Emoji / PrepareEndFrames.js View on Github external
imageMap.forEach((frame, index) => {
			const tempImage = new Jimp(0, 0);
			tempImage.bitmap = new BitmapImage(frame.bitmap).bitmap;
			largeFrame.composite(tempImage, getPixel(index), 0);
		});
		finishedFrames.push(new GifFrame(new BitmapImage(largeFrame.bitmap), {
github GilbertGobbels / GAwesomeBot / Modules / Emoji / Emoji.js View on Github external
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