How to use the omggif.GifReader function in omggif

To help you get started, we’ve selected a few omggif 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 brainshave / sharpvg / gif.js View on Github external
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);
}
github processing / p5.js / src / image / loading_displaying.js View on Github external
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);
        }
github scijs / get-pixels / node-pixels.js View on Github external
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
github seleb / bitsy-hacks / src / character portraits animated.js View on Github external
.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);
github scijs / get-pixels / dom-pixels.js View on Github external
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
github WincerChan / Meme-generator / src / components / gifRender.jsx View on Github external
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) => {
github jtlapp / gifwrap / src / gifcodec.js View on Github external
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);

omggif

omggif is a JavaScript implementation of a GIF 89a encoder and decoder.

MIT
Latest version published 5 years ago

Package Health Score

67 / 100
Full package analysis

Popular omggif functions