Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 => {
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));
})
));
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
})
})
})
}
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 {
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));
});
}));
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), {
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,
};
};