Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function pixels (file_content) {
var img = new GifReader(file_content);
var w = img.width, h = img.height;
var data = new Uint8Array(w * h * 4);
img.decodeAndBlitFrameRGBA(0, data);
return split(data, w, h);
}
function _createGif(
arrayBuffer,
pImg,
successCallback,
failureCallback,
finishCallback
) {
const gifReader = new omggif.GifReader(arrayBuffer);
pImg.width = pImg.canvas.width = gifReader.width;
pImg.height = pImg.canvas.height = gifReader.height;
const frames = [];
const numFrames = gifReader.numFrames();
let framePixels = new Uint8ClampedArray(pImg.width * pImg.height * 4);
if (numFrames > 1) {
const loadGIFFrameIntoImage = (frameNum, gifReader) => {
try {
gifReader.decodeAndBlitFrameRGBA(frameNum, framePixels);
} catch (e) {
p5._friendlyFileLoadError(8, pImg.src);
if (typeof failureCallback === 'function') {
failureCallback(e);
} else {
console.error(e);
}
function handleGIF(data, cb) {
var reader
try {
reader = new GifReader(data)
} catch(err) {
cb(err)
return
}
if(reader.numFrames() > 0) {
var nshape = [reader.numFrames(), reader.height, reader.width, 4]
try {
var ndata = new Uint8Array(nshape[0] * nshape[1] * nshape[2] * nshape[3])
} catch(err) {
cb(err)
return
}
var result = ndarray(ndata, nshape)
try {
for(var i=0; i
.then(function (arrayBuffer) {
var data = new window.Uint8Array(arrayBuffer);
var reader = new GifReader(data);
var numFrames = reader.numFrames();
var width = reader.width;
var height = reader.height;
var prev = document.createElement('canvas');
prev.width = width;
prev.height = height;
var prevCtx = prev.getContext('2d');
var frames = [];
var duration = 0;
for (var i = 0; i < numFrames; ++i) {
var canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext('2d');
var imgData = ctx.createImageData(width, height);
reader.decodeAndBlitFrameRGBA(i, imgData.data);
function handleGif(data, cb) {
var reader
try {
reader = new GifReader(data)
} catch(err) {
cb(err)
return
}
if(reader.numFrames() > 0) {
var nshape = [reader.numFrames(), reader.height, reader.width, 4]
var ndata = new Uint8Array(nshape[0] * nshape[1] * nshape[2] * nshape[3])
var result = ndarray(ndata, nshape)
try {
for(var i=0; i
createGif = async () => {
this.finished = false
var tmp = await fetch(Vendors + this.gifInfo.gif),
response = await tmp.arrayBuffer(),
arrayBufferView = new Uint8Array(response),
gifReader = new omggif.GifReader(arrayBufferView),
frameZeroInfo = gifReader.frameInfo(0),
[, ctx] = this.createCanvasContext(frameZeroInfo.width, frameZeroInfo.height);
return {
index: 0,
time: 0,
ctx: ctx,
gifReader: gifReader,
width: frameZeroInfo.width,
height: frameZeroInfo.height,
captions: document.querySelectorAll('.input.is-info.sentence'),
pixelBuffer: new Uint8ClampedArray(frameZeroInfo.width * frameZeroInfo.height * 4),
}
}
drawCaptions = (info, frameInfo) => {
decodeGif(buffer) {
try {
let reader;
try {
reader = new Omggif.GifReader(buffer);
}
catch (err) {
throw new GifError(err);
}
const frameCount = reader.numFrames();
const frames = [];
const spec = {
width: reader.width,
height: reader.height,
loops: reader.loopCount()
};
spec.usesTransparency = false;
for (let i = 0; i < frameCount; ++i) {
const frameInfo =
this._decodeFrame(reader, i, spec.usesTransparency);