Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getPixl(i) {
let aPos = pos;
pos += images[i][0].bitmap.width + 8;
return aPos;
}
const oneLargeImage = new Jimp(total, height);
let imgMap = images.map(f => {
if (f[i]) return f[i];
else return f[0];
});
imgMap.forEach((f, idx) => {
const ima = new Jimp(1, 1, 0);
ima.bitmap = new GifWrap.BitmapImage(f.bitmap).bitmap;
oneLargeImage.composite(ima, getPixl(idx), 0);
});
f.push(new GifWrap.GifFrame(new GifWrap.BitmapImage(oneLargeImage.bitmap), {
delayCentisecs: 2
}));
}
console.log("Returned image has", f.length, "frames");
return f;
};
const getPixel = index => {
const aPos = pos;
pos += images[index][0].bitmap.width + 8;
return aPos;
};
const largeFrame = new Jimp(totalWidth, totalHeight);
const imageMap = images.map(frame => {
if (frame[i]) return frame[i];
return frame[0];
});
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), {
delayCentisecs: 2,
}));
}
return finishedFrames;
};
const data = await Promise.all(results.map(async result => {
if (result.animated) {
const { body } = await get(result.url);
return prepareFrames(result, body);
}
const image = await read(result.url);
return prepareFrames(result, new GifFrame(new BitmapImage(image.bitmap)));
}));
const rawFrames = data.map(img => img.frames);
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
})
})
})
}
pp.on("quantizeImage", async ({data, width, height}, cb) => {
workingCount++;
pp.send("workingCount", {id: WORKER_ID, working: workingCount});
const f = new GifWrap.GifFrame({width, height, data: Buffer.from(data, "base64")});
GifWrap.GifUtil.quantizeDekker([f]);
workingCount--;
pp.send("workingCount", {id: WORKER_ID, working: workingCount});
cb({width: f.bitmap.width, height: f.bitmap.height, data: f.bitmap.data.toString("base64")});
});
(async () => {
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));
})
));
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));
});
}));
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 {