Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

gifshot is now installed via npm.

Benjamin5ba68aa4c9dc
diff --git a/Gruntfile.js b/Gruntfile.js
index 62623958d..2286bd61a 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -170,6 +170,8 @@ module.exports = function(grunt) {
"node_modules/lodash/lodash.min.js",
"node_modules/bluebird/js/browser/bluebird.js",
"node_modules/bluebird/js/browser/bluebird.min.js",
+ "node_modules/gifshot/demo/gifshot.custom.js",
+ "node_modules/gifshot/demo/gifshot.custom.min.js",
"node_modules/promise-queue/lib/index.js",
"node_modules/openlayers/dist/ol-debug.js"
],
diff --git a/package.json b/package.json
index 12ba89542..a8e4100eb 100644
--- a/package.json
+++ b/package.json
@@ -35,6 +35,7 @@
"lodash": "^4.15.0",
"moment": "2.13.x",
"openlayers": "3.19.x",
+ "gifshot": "https://github.com/nasa-gibs/gifshot/archive/4.2.0.tar.gz",
"phantomjs": "2.1.x",
"promise-queue": "^2.2.3",
"react": "^15.3.1",
diff --git a/web/ext/anim/gifshot/gifshot.js b/web/ext/anim/gifshot/gifshot.js
deleted file mode 100644
index 97d5340ef..000000000
--- a/web/ext/anim/gifshot/gifshot.js
+++ /dev/null
@@ -1,1767 +0,0 @@
-/*Copyrights for code authored by Yahoo Inc. is licensed under the following terms:
-MIT License
-Copyright 2015 Yahoo Inc.
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-;(function(window, document, navigator, undefined) {
-var utils, error, defaultOptions, isSupported, isWebCamGIFSupported, isExistingImagesGIFSupported, isExistingVideoGIFSupported, NeuQuant, processFrameWorker, gifWriter, AnimatedGIF, getBase64GIF, existingImages, screenShot, videoStream, stopVideoStreaming, createAndGetGIF, existingVideo, existingWebcam, createGIF, takeSnapShot, API;
-utils = function () {
- var utils = {
- 'URL': window.URL || window.webkitURL || window.mozURL || window.msURL,
- 'getUserMedia': function () {
- var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
- return getUserMedia ? getUserMedia.bind(navigator) : getUserMedia;
- }(),
- 'requestAnimFrame': window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame,
- 'requestTimeout': function (callback, delay) {
- callback = callback || utils.noop;
- delay = delay || 0;
- if (!utils.requestAnimFrame) {
- return setTimeout(callback, delay);
- }
- var start = new Date().getTime(), handle = new Object(), requestAnimFrame = utils.requestAnimFrame;
- function loop() {
- var current = new Date().getTime(), delta = current - start;
- delta >= delay ? callback.call() : handle.value = requestAnimFrame(loop);
- }
- handle.value = requestAnimFrame(loop);
- return handle;
- },
- 'Blob': window.Blob || window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder,
- 'btoa': function () {
- var btoa = window.btoa || function (input) {
- var output = '', i = 0, l = input.length, key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', chr1, chr2, chr3, enc1, enc2, enc3, enc4;
- while (i < l) {
- chr1 = input.charCodeAt(i++);
- chr2 = input.charCodeAt(i++);
- chr3 = input.charCodeAt(i++);
- enc1 = chr1 >> 2;
- enc2 = (chr1 & 3) << 4 | chr2 >> 4;
- enc3 = (chr2 & 15) << 2 | chr3 >> 6;
- enc4 = chr3 & 63;
- if (isNaN(chr2))
- enc3 = enc4 = 64;
- else if (isNaN(chr3))
- enc4 = 64;
- output = output + key.charAt(enc1) + key.charAt(enc2) + key.charAt(enc3) + key.charAt(enc4);
- }
- return output;
- };
- return btoa ? btoa.bind(window) : function () {
- };
- }(),
- 'isObject': function (obj) {
- return obj && Object.prototype.toString.call(obj) === '[object Object]';
- },
- 'isEmptyObject': function (obj) {
- return utils.isObject(obj) && !Object.keys(obj).length;
- },
- 'isArray': function (arr) {
- return arr && Array.isArray(arr);
- },
- 'isFunction': function (func) {
- return func && typeof func === 'function';
- },
- 'isElement': function (elem) {
- return elem && elem.nodeType === 1;
- },
- 'isString': function (value) {
- return typeof value === 'string' || Object.prototype.toString.call(value) === '[object String]';
- },
- 'isSupported': {
- 'canvas': function () {
- var el = document.createElement('canvas');
- return el && el.getContext && el.getContext('2d');
- },
- 'webworkers': function () {
- return window.Worker;
- },
- 'blob': function () {
- return utils.Blob;
- },
- 'Uint8Array': function () {
- return window.Uint8Array;
- },
- 'Uint32Array': function () {
- return window.Uint32Array;
- },
- 'videoCodecs': function () {
- var testEl = document.createElement('video'), supportObj = {
- 'mp4': false,
- 'h264': false,
- 'ogv': false,
- 'ogg': false,
- 'webm': false
- };
- try {
- if (testEl && testEl.canPlayType) {
- supportObj.mp4 = testEl.canPlayType('video/mp4; codecs="mp4v.20.8"') !== '';
- supportObj.h264 = (testEl.canPlayType('video/mp4; codecs="avc1.42E01E"') || testEl.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')) !== '';
- supportObj.ogv = testEl.canPlayType('video/ogg; codecs="theora"') !== '';
- supportObj.ogg = testEl.canPlayType('video/ogg; codecs="theora"') !== '';
- supportObj.webm = testEl.canPlayType('video/webm; codecs="vp8, vorbis"') !== -1;
- }
- } catch (e) {
- }
- return supportObj;
- }()
- },
- 'noop': function () {
- },
- 'each': function (collection, callback) {
- var x, len;
- if (utils.isArray(collection)) {
- x = -1;
- len = collection.length;
- while (++x < len) {
- if (callback(x, collection[x]) === false) {
- break;
- }
- }
- } else if (utils.isObject(collection)) {
- for (x in collection) {
- if (collection.hasOwnProperty(x)) {
- if (callback(x, collection[x]) === false) {
- break;
- }
- }
- }
- }
- },
- 'mergeOptions': function deepMerge(defaultOptions, userOptions) {
- if (!utils.isObject(defaultOptions) || !utils.isObject(userOptions) || !Object.keys) {
- return;
- }
- var newObj = {};
- utils.each(defaultOptions, function (key, val) {
- newObj[key] = defaultOptions[key];
- });
- utils.each(userOptions, function (key, val) {
- var currentUserOption = userOptions[key];
- if (!utils.isObject(currentUserOption)) {
- newObj[key] = currentUserOption;
- } else {
- if (!defaultOptions[key]) {
- newObj[key] = currentUserOption;
- } else {
- newObj[key] = deepMerge(defaultOptions[key], currentUserOption);
- }
- }
- });
- return newObj;
- },
- 'setCSSAttr': function (elem, attr, val) {
- if (!utils.isElement(elem)) {
- return;
- }
- if (utils.isString(attr) && utils.isString(val)) {
- elem.style[attr] = val;
- } else if (utils.isObject(attr)) {
- utils.each(attr, function (key, val) {
- elem.style[key] = val;
- });
- }
- },
- 'removeElement': function (node) {
- if (!utils.isElement(node)) {
- return;
- }
- if (node.parentNode) {
- node.parentNode.removeChild(node);
- }
- },
- 'createWebWorker': function (content) {
- if (!utils.isString(content)) {
- return {};
- }
- try {
- var blob = new utils.Blob([content], { 'type': 'text/javascript' }), objectUrl = utils.URL.createObjectURL(blob), worker = new Worker(objectUrl);
- return {
- 'objectUrl': objectUrl,
- 'worker': worker
- };
- } catch (e) {
- return '' + e;
- }
- },
- 'getExtension': function (src) {
- return src.substr(src.lastIndexOf('.') + 1, src.length);
- },
- 'getFontSize': function (options) {
- options = options || {};
- if (!document.body || options.resizeFont === false) {
- return options.fontSize;
- }
- var text = options.text, containerWidth = options.gifWidth, fontSize = parseInt(options.fontSize, 10), minFontSize = parseInt(options.minFontSize, 10), div = document.createElement('div'), span = document.createElement('span');
- div.setAttribute('width', containerWidth);
- div.appendChild(span);
- span.innerHTML = text;
- span.style.fontSize = fontSize + 'px';
- span.style.textIndent = '-9999px';
- span.style.visibility = 'hidden';
- document.body.appendChild(span);
- while (span.offsetWidth > containerWidth && fontSize >= minFontSize) {
- span.style.fontSize = --fontSize + 'px';
- }
- document.body.removeChild(span);
- return fontSize + 'px';
- },
- 'webWorkerError': false
- };
- return utils;
-}();
-error = function (utils) {
- var error = {
- 'validate': function (skipObj) {
- skipObj = utils.isObject(skipObj) ? skipObj : {};
- var errorObj = {};
- utils.each(error.validators, function (indece, currentValidator) {
- var errorCode = currentValidator.errorCode;
- if (!skipObj[errorCode] && !currentValidator.condition) {
- errorObj = currentValidator;
- errorObj.error = true;
- return false;
- }
- });
- delete errorObj.condition;
- return errorObj;
- },
- 'isValid': function (skipObj) {
- var errorObj = error.validate(skipObj), isValid = errorObj.error !== true ? true : false;
- return isValid;
- },
- 'validators': [
- {
- 'condition': utils.isFunction(utils.getUserMedia),
- 'errorCode': 'getUserMedia',
- 'errorMsg': 'The getUserMedia API is not supported in your browser'
- },
- {
- 'condition': utils.isSupported.canvas(),
- 'errorCode': 'canvas',
- 'errorMsg': 'Canvas elements are not supported in your browser'
- },
- {
- 'condition': utils.isSupported.webworkers(),
- 'errorCode': 'webworkers',
- 'errorMsg': 'The Web Workers API is not supported in your browser'
- },
- {
- 'condition': utils.isFunction(utils.URL),
- 'errorCode': 'window.URL',
- 'errorMsg': 'The window.URL API is not supported in your browser'
- },
- {
- 'condition': utils.isSupported.blob(),
- 'errorCode': 'window.Blob',
- 'errorMsg': 'The window.Blob File API is not supported in your browser'
- },
- {
- 'condition': utils.isSupported.Uint8Array(),
- 'errorCode': 'window.Uint8Array',
- 'errorMsg': 'The window.Uint8Array function constructor is not supported in your browser'
- },
- {
- 'condition': utils.isSupported.Uint32Array(),
- 'errorCode': 'window.Uint32Array',
- 'errorMsg': 'The window.Uint32Array function constructor is not supported in your browser'
- }
- ],
- 'messages': {
- 'videoCodecs': {
- 'errorCode': 'videocodec',
- 'errorMsg': 'The video codec you are trying to use is not supported in your browser'
- }
- }
- };
- return error;
-}(utils);
-defaultOptions = {
- 'sampleInterval': 10,
- 'numWorkers': 2,
- 'gifWidth': 200,
- 'gifHeight': 200,
- 'interval': 0.1,
- 'numFrames': 10,
- 'keepCameraOn': false,
- 'images': [],
- 'video': null,
- 'webcamVideoElement': null,
- 'cameraStream': null,
- 'text': '',
- 'fontWeight': 'normal',
- 'fontSize': '16px',
- 'minFontSize': '10px',
- 'resizeFont': false,
- 'fontFamily': 'sans-serif',
- 'fontColor': '#ffffff',
- 'textAlign': 'center',
- 'textBaseline': 'bottom',
- 'textXCoordinate': null,
- 'textYCoordinate': null,
- 'progressCallback': function (captureProgress) {
- },
- 'completeCallback': function () {
- },
- 'saveRenderingContexts': false,
- 'savedRenderingContexts': [],
- 'crossOrigin': 'Anonymous'
-};
-isSupported = function () {
- return error.isValid();
-};
-isWebCamGIFSupported = function () {
- return error.isValid();
-};
-isExistingImagesGIFSupported = function () {
- var skipObj = { 'getUserMedia': true };
- return error.isValid(skipObj);
-};
-isExistingVideoGIFSupported = function (codecs) {
- var isSupported = false, hasValidCodec = false;
- if (utils.isArray(codecs) && codecs.length) {
- utils.each(codecs, function (indece, currentCodec) {
- if (utils.isSupported.videoCodecs[currentCodec]) {
- hasValidCodec = true;
- }
- });
- if (!hasValidCodec) {
- return false;
- }
- } else if (utils.isString(codecs) && codecs.length) {
- if (!utils.isSupported.videoCodecs[codecs]) {
- return false;
- }
- }
- return error.isValid({ 'getUserMedia': true });
-};
-NeuQuant = function () {
- function NeuQuant() {
- var netsize = 256;
- var prime1 = 499;
- var prime2 = 491;
- var prime3 = 487;
- var prime4 = 503;
- var minpicturebytes = 3 * prime4;
- var maxnetpos = netsize - 1;
- var netbiasshift = 4;
- var ncycles = 100;
- var intbiasshift = 16;
- var intbias = 1 << intbiasshift;
- var gammashift = 10;
- var gamma = 1 << gammashift;
- var betashift = 10;
- var beta = intbias >> betashift;
- var betagamma = intbias << gammashift - betashift;
- var initrad = netsize >> 3;
- var radiusbiasshift = 6;
- var radiusbias = 1 << radiusbiasshift;
- var initradius = initrad * radiusbias;
- var radiusdec = 30;
- var alphabiasshift = 10;
- var initalpha = 1 << alphabiasshift;
- var alphadec;
- var radbiasshift = 8;
- var radbias = 1 << radbiasshift;
- var alpharadbshift = alphabiasshift + radbiasshift;
- var alpharadbias = 1 << alpharadbshift;
- var thepicture;
- var lengthcount;
- var samplefac;
- var network;
- var netindex = [];
- var bias = [];
- var freq = [];
- var radpower = [];
- function NeuQuantConstructor(thepic, len, sample) {
- var i;
- var p;
- thepicture = thepic;
- lengthcount = len;
- samplefac = sample;
- network = new Array(netsize);
- for (i = 0; i < netsize; i++) {
- network[i] = new Array(4);
- p = network[i];
- p[0] = p[1] = p[2] = (i << netbiasshift + 8) / netsize | 0;
- freq[i] = intbias / netsize | 0;
- bias[i] = 0;
- }
- }
- function colorMap() {
- var map = [];
- var index = new Array(netsize);
- for (var i = 0; i < netsize; i++)
- index[network[i][3]] = i;
- var k = 0;
- for (var l = 0; l < netsize; l++) {
- var j = index[l];
- map[k++] = network[j][0];
- map[k++] = network[j][1];
- map[k++] = network[j][2];
- }
- return map;
- }
- function inxbuild() {
- var i;
- var j;
- var smallpos;
- var smallval;
- var p;
- var q;
- var previouscol;
- var startpos;
- previouscol = 0;
- startpos = 0;
- for (i = 0; i < netsize; i++) {
- p = network[i];
- smallpos = i;
- smallval = p[1];
- for (j = i + 1; j < netsize; j++) {
- q = network[j];
- if (q[1] < smallval) {
- smallpos = j;
- smallval = q[1];
- }
- }
- q = network[smallpos];
- if (i != smallpos) {
- j = q[0];
- q[0] = p[0];
- p[0] = j;
- j = q[1];
- q[1] = p[1];
- p[1] = j;
- j = q[2];
- q[2] = p[2];
- p[2] = j;
- j = q[3];
- q[3] = p[3];
- p[3] = j;
- }
- if (smallval != previouscol) {
- netindex[previouscol] = startpos + i >> 1;
- for (j = previouscol + 1; j < smallval; j++) {
- netindex[j] = i;
- }
- previouscol = smallval;
- startpos = i;
- }
- }
- netindex[previouscol] = startpos + maxnetpos >> 1;
- for (j = previouscol + 1; j < 256; j++) {
- netindex[j] = maxnetpos;
- }
- }
- function learn() {
- var i;
- var j;
- var b;
- var g;
- var r;
- var radius;
- var rad;
- var alpha;
- var step;
- var delta;
- var samplepixels;
- var p;
- var pix;
- var lim;
- if (lengthcount < minpicturebytes) {
- samplefac = 1;
- }
- alphadec = 30 + (samplefac - 1) / 3;
- p = thepicture;
- pix = 0;
- lim = lengthcount;
- samplepixels = lengthcount / (3 * samplefac);
- delta = samplepixels / ncycles | 0;
- alpha = initalpha;
- radius = initradius;
- rad = radius >> radiusbiasshift;
- if (rad <= 1) {
- rad = 0;
- }
- for (i = 0; i < rad; i++) {
- radpower[i] = alpha * ((rad * rad - i * i) * radbias / (rad * rad));
- }
- if (lengthcount < minpicturebytes) {
- step = 3;
- } else if (lengthcount % prime1 !== 0) {
- step = 3 * prime1;
- } else {
- if (lengthcount % prime2 !== 0) {
- step = 3 * prime2;
- } else {
- if (lengthcount % prime3 !== 0) {
- step = 3 * prime3;
- } else {
- step = 3 * prime4;
- }
- }
- }
- i = 0;
- while (i < samplepixels) {
- b = (p[pix + 0] & 255) << netbiasshift;
- g = (p[pix + 1] & 255) << netbiasshift;
- r = (p[pix + 2] & 255) << netbiasshift;
- j = contest(b, g, r);
- altersingle(alpha, j, b, g, r);
- if (rad !== 0) {
- alterneigh(rad, j, b, g, r);
- }
- pix += step;
- if (pix >= lim) {
- pix -= lengthcount;
- }
- i++;
- if (delta === 0) {
- delta = 1;
- }
- if (i % delta === 0) {
- alpha -= alpha / alphadec;
- radius -= radius / radiusdec;
- rad = radius >> radiusbiasshift;
- if (rad <= 1) {
- rad = 0;
- }
- for (j = 0; j < rad; j++) {
- radpower[j] = alpha * ((rad * rad - j * j) * radbias / (rad * rad));
- }
- }
- }
- }
- function map(b, g, r) {
- var i;
- var j;
- var dist;
- var a;
- var bestd;
- var p;
- var best;
- bestd = 1000;
- best = -1;
- i = netindex[g];
- j = i - 1;
- while (i < netsize || j >= 0) {
- if (i < netsize) {
- p = network[i];
- dist = p[1] - g;
- if (dist >= bestd) {
- i = netsize;
- } else {
- i++;
- if (dist < 0) {
- dist = -dist;
- }
- a = p[0] - b;
- if (a < 0) {
- a = -a;
- }
- dist += a;
- if (dist < bestd) {
- a = p[2] - r;
- if (a < 0) {
- a = -a;
- }
- dist += a;
- if (dist < bestd) {
- bestd = dist;
- best = p[3];
- }
- }
- }
- }
- if (j >= 0) {
- p = network[j];
- dist = g - p[1];
- if (dist >= bestd) {
- j = -1;
- } else {
- j--;
- if (dist < 0) {
- dist = -dist;
- }
- a = p[0] - b;
- if (a < 0) {
- a = -a;
- }
- dist += a;
- if (dist < bestd) {
- a = p[2] - r;
- if (a < 0) {
- a = -a;
- }
- dist += a;
- if (dist < bestd) {
- bestd = dist;
- best = p[3];
- }
- }
- }
- }
- }
- return best;
- }
- function process() {
- learn();
- unbiasnet();
- inxbuild();
- return colorMap();
- }
- function unbiasnet() {
- var i;
- var j;
- for (i = 0; i < netsize; i++) {
- network[i][0] >>= netbiasshift;
- network[i][1] >>= netbiasshift;
- network[i][2] >>= netbiasshift;
- network[i][3] = i;
- }
- }
- function alterneigh(rad, i, b, g, r) {
- var j;
- var k;
- var lo;
- var hi;
- var a;
- var m;
- var p;
- lo = i - rad;
- if (lo < -1) {
- lo = -1;
- }
- hi = i + rad;
- if (hi > netsize) {
- hi = netsize;
- }
- j = i + 1;
- k = i - 1;
- m = 1;
- while (j < hi || k > lo) {
- a = radpower[m++];
- if (j < hi) {
- p = network[j++];
- try {
- p[0] -= a * (p[0] - b) / alpharadbias | 0;
- p[1] -= a * (p[1] - g) / alpharadbias | 0;
- p[2] -= a * (p[2] - r) / alpharadbias | 0;
- } catch (e) {
- }
- }
- if (k > lo) {
- p = network[k--];
- try {
- p[0] -= a * (p[0] - b) / alpharadbias | 0;
- p[1] -= a * (p[1] - g) / alpharadbias | 0;
- p[2] -= a * (p[2] - r) / alpharadbias | 0;
- } catch (e) {
- }
- }
- }
- }
- function altersingle(alpha, i, b, g, r) {
- var n = network[i];
- var alphaMult = alpha / initalpha;
- n[0] -= alphaMult * (n[0] - b) | 0;
- n[1] -= alphaMult * (n[1] - g) | 0;
- n[2] -= alphaMult * (n[2] - r) | 0;
- }
- function contest(b, g, r) {
- var i;
- var dist;
- var a;
- var biasdist;
- var betafreq;
- var bestpos;
- var bestbiaspos;
- var bestd;
- var bestbiasd;
- var n;
- bestd = ~(1 << 31);
- bestbiasd = bestd;
- bestpos = -1;
- bestbiaspos = bestpos;
- for (i = 0; i < netsize; i++) {
- n = network[i];
- dist = n[0] - b;
- if (dist < 0) {
- dist = -dist;
- }
- a = n[1] - g;
- if (a < 0) {
- a = -a;
- }
- dist += a;
- a = n[2] - r;
- if (a < 0) {
- a = -a;
- }
- dist += a;
- if (dist < bestd) {
- bestd = dist;
- bestpos = i;
- }
- biasdist = dist - (bias[i] >> intbiasshift - netbiasshift);
- if (biasdist < bestbiasd) {
- bestbiasd = biasdist;
- bestbiaspos = i;
- }
- betafreq = freq[i] >> betashift;
- freq[i] -= betafreq;
- bias[i] += betafreq << gammashift;
- }
- freq[bestpos] += beta;
- bias[bestpos] -= betagamma;
- return bestbiaspos;
- }
- NeuQuantConstructor.apply(this, arguments);
- var exports = {};
- exports.map = map;
- exports.process = process;
- return exports;
- }
- return NeuQuant;
-}();
-processFrameWorker = function (NeuQuant) {
- var workerCode = function () {
- try {
- self.onmessage = function (ev) {
- var data = ev.data || {};
- var response;
- if (data.gifshot) {
- response = workerMethods.run(data);
- postMessage(response);
- }
- };
- } catch (e) {
- }
- var workerMethods = {
- 'dataToRGB': function (data, width, height) {
- var i = 0, length = width * height * 4, rgb = [];
- while (i < length) {
- rgb.push(data[i++]);
- rgb.push(data[i++]);
- rgb.push(data[i++]);
- i++;
- }
- return rgb;
- },
- 'componentizedPaletteToArray': function (paletteRGB) {
- var paletteArray = [], i, r, g, b;
- for (i = 0; i < paletteRGB.length; i += 3) {
- r = paletteRGB[i];
- g = paletteRGB[i + 1];
- b = paletteRGB[i + 2];
- paletteArray.push(r << 16 | g << 8 | b);
- }
- return paletteArray;
- },
- 'processFrameWithQuantizer': function (imageData, width, height, sampleInterval) {
- var rgbComponents = this.dataToRGB(imageData, width, height), nq = new NeuQuant(rgbComponents, rgbComponents.length, sampleInterval), paletteRGB = nq.process(), paletteArray = new Uint32Array(this.componentizedPaletteToArray(paletteRGB)), numberPixels = width * height, indexedPixels = new Uint8Array(numberPixels), k = 0, i, r, g, b;
- for (i = 0; i < numberPixels; i++) {
- r = rgbComponents[k++];
- g = rgbComponents[k++];
- b = rgbComponents[k++];
- indexedPixels[i] = nq.map(r, g, b);
- }
- return {
- pixels: indexedPixels,
- palette: paletteArray
- };
- },
- 'run': function (frame) {
- var width = frame.width, height = frame.height, imageData = frame.data, palette = frame.palette, sampleInterval = frame.sampleInterval;
- return this.processFrameWithQuantizer(imageData, width, height, sampleInterval);
- }
- };
- return workerMethods;
- };
- return workerCode;
-}(NeuQuant);
-gifWriter = function gifWriter(buf, width, height, gopts) {
- var p = 0;
- gopts = gopts === undefined ? {} : gopts;
- var loop_count = gopts.loop === undefined ? null : gopts.loop;
- var global_palette = gopts.palette === undefined ? null : gopts.palette;
- if (width <= 0 || height <= 0 || width > 65535 || height > 65535)
- throw 'Width/Height invalid.';
- function check_palette_and_num_colors(palette) {
- var num_colors = palette.length;
- if (num_colors < 2 || num_colors > 256 || num_colors & num_colors - 1)
- throw 'Invalid code/color length, must be power of 2 and 2 .. 256.';
- return num_colors;
- }
- buf[p++] = 71;
- buf[p++] = 73;
- buf[p++] = 70;
- buf[p++] = 56;
- buf[p++] = 57;
- buf[p++] = 97;
- var gp_num_colors_pow2 = 0;
- var background = 0;
- buf[p++] = width & 255;
- buf[p++] = width >> 8 & 255;
- buf[p++] = height & 255;
- buf[p++] = height >> 8 & 255;
- buf[p++] = (global_palette !== null ? 128 : 0) | gp_num_colors_pow2;
- buf[p++] = background;
- buf[p++] = 0;
- if (loop_count !== null) {
- if (loop_count < 0 || loop_count > 65535)
- throw 'Loop count invalid.';
- buf[p++] = 33;
- buf[p++] = 255;
- buf[p++] = 11;
- buf[p++] = 78;
- buf[p++] = 69;
- buf[p++] = 84;
- buf[p++] = 83;
- buf[p++] = 67;
- buf[p++] = 65;
- buf[p++] = 80;
- buf[p++] = 69;
- buf[p++] = 50;
- buf[p++] = 46;
- buf[p++] = 48;
- buf[p++] = 3;
- buf[p++] = 1;
- buf[p++] = loop_count & 255;
- buf[p++] = loop_count >> 8 & 255;
- buf[p++] = 0;
- }
- var ended = false;
- this.addFrame = function (x, y, w, h, indexed_pixels, opts) {
- if (ended === true) {
- --p;
- ended = false;
- }
- opts = opts === undefined ? {} : opts;
- if (x < 0 || y < 0 || x > 65535 || y > 65535)
- throw 'x/y invalid.';
- if (w <= 0 || h <= 0 || w > 65535 || h > 65535)
- throw 'Width/Height invalid.';
- if (indexed_pixels.length < w * h)
- throw 'Not enough pixels for the frame size.';
- var using_local_palette = true;
- var palette = opts.palette;
- if (palette === undefined || palette === null) {
- using_local_palette = false;
- palette = global_palette;
- }
- if (palette === undefined || palette === null)
- throw 'Must supply either a local or global palette.';
- var num_colors = check_palette_and_num_colors(palette);
- var min_code_size = 0;
- while (num_colors >>= 1)
- ++min_code_size;
- num_colors = 1 << min_code_size;
- var delay = opts.delay === undefined ? 0 : opts.delay;
- var disposal = opts.disposal === undefined ? 0 : opts.disposal;
- if (disposal < 0 || disposal > 3)
- throw 'Disposal out of range.';
- var use_transparency = false;
- var transparent_index = 0;
- if (opts.transparent !== undefined && opts.transparent !== null) {
- use_transparency = true;
- transparent_index = opts.transparent;
- if (transparent_index < 0 || transparent_index >= num_colors)
- throw 'Transparent color index.';
- }
- if (disposal !== 0 || use_transparency || delay !== 0) {
- buf[p++] = 33;
- buf[p++] = 249;
- buf[p++] = 4;
- buf[p++] = disposal << 2 | (use_transparency === true ? 1 : 0);
- buf[p++] = delay & 255;
- buf[p++] = delay >> 8 & 255;
- buf[p++] = transparent_index;
- buf[p++] = 0;
- }
- buf[p++] = 44;
- buf[p++] = x & 255;
- buf[p++] = x >> 8 & 255;
- buf[p++] = y & 255;
- buf[p++] = y >> 8 & 255;
- buf[p++] = w & 255;
- buf[p++] = w >> 8 & 255;
- buf[p++] = h & 255;
- buf[p++] = h >> 8 & 255;
- buf[p++] = using_local_palette === true ? 128 | min_code_size - 1 : 0;
- if (using_local_palette === true) {
- for (var i = 0, il = palette.length; i < il; ++i) {
- var rgb = palette[i];
- buf[p++] = rgb >> 16 & 255;
- buf[p++] = rgb >> 8 & 255;
- buf[p++] = rgb & 255;
- }
- }
- p = GifWriterOutputLZWCodeStream(buf, p, min_code_size < 2 ? 2 : min_code_size, indexed_pixels);
- };
- this.end = function () {
- if (ended === false) {
- buf[p++] = 59;
- ended = true;
- }
- return p;
- };
- function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) {
- buf[p++] = min_code_size;
- var cur_subblock = p++;
- var clear_code = 1 << min_code_size;
- var code_mask = clear_code - 1;
- var eoi_code = clear_code + 1;
- var next_code = eoi_code + 1;
- var cur_code_size = min_code_size + 1;
- var cur_shift = 0;
- var cur = 0;
- function emit_bytes_to_buffer(bit_block_size) {
- while (cur_shift >= bit_block_size) {
- buf[p++] = cur & 255;
- cur >>= 8;
- cur_shift -= 8;
- if (p === cur_subblock + 256) {
- buf[cur_subblock] = 255;
- cur_subblock = p++;
- }
- }
- }
- function emit_code(c) {
- cur |= c << cur_shift;
- cur_shift += cur_code_size;
- emit_bytes_to_buffer(8);
- }
- var ib_code = index_stream[0] & code_mask;
- var code_table = {};
- emit_code(clear_code);
- for (var i = 1, il = index_stream.length; i < il; ++i) {
- var k = index_stream[i] & code_mask;
- var cur_key = ib_code << 8 | k;
- var cur_code = code_table[cur_key];
- if (cur_code === undefined) {
- cur |= ib_code << cur_shift;
- cur_shift += cur_code_size;
- while (cur_shift >= 8) {
- buf[p++] = cur & 255;
- cur >>= 8;
- cur_shift -= 8;
- if (p === cur_subblock + 256) {
- buf[cur_subblock] = 255;
- cur_subblock = p++;
- }
- }
- if (next_code === 4096) {
- emit_code(clear_code);
- next_code = eoi_code + 1;
- cur_code_size = min_code_size + 1;
- code_table = {};
- } else {
- if (next_code >= 1 << cur_code_size)
- ++cur_code_size;
- code_table[cur_key] = next_code++;
- }
- ib_code = k;
- } else {
- ib_code = cur_code;
- }
- }
- emit_code(ib_code);
- emit_code(eoi_code);
- emit_bytes_to_buffer(1);
- if (cur_subblock + 1 === p) {
- buf[cur_subblock] = 0;
- } else {
- buf[cur_subblock] = p - cur_subblock - 1;
- buf[p++] = 0;
- }
- return p;
- }
-};
-AnimatedGIF = function (utils, frameWorkerCode, NeuQuant, GifWriter) {
- var AnimatedGIF = function (options) {
- this.canvas = null;
- this.ctx = null;
- this.repeat = 0;
- this.frames = [];
- this.numRenderedFrames = 0;
- this.onRenderCompleteCallback = utils.noop;
- this.onRenderProgressCallback = utils.noop;
- this.workers = [];
- this.availableWorkers = [];
- this.generatingGIF = false;
- this.options = options;
- this.initializeWebWorkers(options);
- };
- AnimatedGIF.prototype = {
- 'workerMethods': frameWorkerCode(),
- 'initializeWebWorkers': function (options) {
- var processFrameWorkerCode = NeuQuant.toString() + '(' + frameWorkerCode.toString() + '());', webWorkerObj, objectUrl, webWorker, numWorkers, x = -1, workerError = '';
- numWorkers = options.numWorkers;
- while (++x < numWorkers) {
- webWorkerObj = utils.createWebWorker(processFrameWorkerCode);
- if (utils.isObject(webWorkerObj)) {
- objectUrl = webWorkerObj.objectUrl;
- webWorker = webWorkerObj.worker;
- this.workers.push({
- 'worker': webWorker,
- 'objectUrl': objectUrl
- });
- this.availableWorkers.push(webWorker);
- } else {
- workerError = webWorkerObj;
- utils.webWorkerError = !!webWorkerObj;
- }
- }
- this.workerError = workerError;
- this.canvas = document.createElement('canvas');
- this.canvas.width = options.gifWidth;
- this.canvas.height = options.gifHeight;
- this.ctx = this.canvas.getContext('2d');
- this.frames = [];
- },
- 'getWorker': function () {
- return this.availableWorkers.pop();
- },
- 'freeWorker': function (worker) {
- this.availableWorkers.push(worker);
- },
- 'byteMap': function () {
- var byteMap = [];
- for (var i = 0; i < 256; i++) {
- byteMap[i] = String.fromCharCode(i);
- }
- return byteMap;
- }(),
- 'bufferToString': function (buffer) {
- var numberValues = buffer.length, str = '', x = -1;
- while (++x < numberValues) {
- str += this.byteMap[buffer[x]];
- }
- return str;
- },
- 'onFrameFinished': function (progressCallback) {
- var self = this, frames = self.frames, options = self.options;
- hasExistingImages = !!(options.images || []).length;
- allDone = frames.every(function (frame) {
- return !frame.beingProcessed && frame.done;
- });
- self.numRenderedFrames++;
- if (hasExistingImages) {
- progressCallback(self.numRenderedFrames / frames.length);
- }
- self.onRenderProgressCallback(self.numRenderedFrames * 0.75 / frames.length);
- if (allDone) {
- if (!self.generatingGIF) {
- self.generateGIF(frames, self.onRenderCompleteCallback);
- }
- } else {
- utils.requestTimeout(function () {
- self.processNextFrame();
- }, 1);
- }
- },
- 'processFrame': function (position) {
- var AnimatedGifContext = this, options = this.options, progressCallback = options.progressCallback, sampleInterval = options.sampleInterval, frames = this.frames, frame, worker, done = function (ev) {
- var data = ev.data;
- delete frame.data;
- frame.pixels = Array.prototype.slice.call(data.pixels);
- frame.palette = Array.prototype.slice.call(data.palette);
- frame.done = true;
- frame.beingProcessed = false;
- AnimatedGifContext.freeWorker(worker);
- AnimatedGifContext.onFrameFinished(progressCallback);
- };
- frame = frames[position];
- if (frame.beingProcessed || frame.done) {
- this.onFrameFinished();
- return;
- }
- frame.sampleInterval = sampleInterval;
- frame.beingProcessed = true;
- frame.gifshot = true;
- worker = this.getWorker();
- if (worker) {
- worker.onmessage = done;
- worker.postMessage(frame);
- } else {
- done({ 'data': AnimatedGifContext.workerMethods.run(frame) });
- }
- },
- 'startRendering': function (completeCallback) {
- this.onRenderCompleteCallback = completeCallback;
- for (var i = 0; i < this.options.numWorkers && i < this.frames.length; i++) {
- this.processFrame(i);
- }
- },
- 'processNextFrame': function () {
- var position = -1;
- for (var i = 0; i < this.frames.length; i++) {
- var frame = this.frames[i];
- if (!frame.done && !frame.beingProcessed) {
- position = i;
- break;
- }
- }
- if (position >= 0) {
- this.processFrame(position);
- }
- },
- 'generateGIF': function (frames, callback) {
- var buffer = [], gifOptions = { 'loop': this.repeat }, options = this.options, interval = options.interval, existingImages = options.images, hasExistingImages = !!existingImages.length, height = options.gifHeight, width = options.gifWidth, gifWriter = new GifWriter(buffer, width, height, gifOptions), onRenderProgressCallback = this.onRenderProgressCallback, delay = hasExistingImages ? interval * 100 : 0, bufferToString, gif;
- this.generatingGIF = true;
- utils.each(frames, function (iterator, frame) {
- var framePalette = frame.palette;
- onRenderProgressCallback(0.75 + 0.25 * frame.position * 1 / frames.length);
- gifWriter.addFrame(0, 0, width, height, frame.pixels, {
- palette: framePalette,
- delay: delay
- });
- });
- gifWriter.end();
- onRenderProgressCallback(1);
- this.frames = [];
- this.generatingGIF = false;
- if (utils.isFunction(callback)) {
- bufferToString = this.bufferToString(buffer);
- gif = 'data:image/gif;base64,' + utils.btoa(bufferToString);
- callback(gif);
- }
- },
- 'setRepeat': function (r) {
- this.repeat = r;
- },
- 'addFrame': function (element, gifshotOptions, frameText) {
- gifshotOptions = utils.isObject(gifshotOptions) ? gifshotOptions : {};
- var self = this, ctx = self.ctx, options = self.options, width = options.gifWidth, height = options.gifHeight, gifHeight = gifshotOptions.gifHeight, gifWidth = gifshotOptions.gifWidth, text = gifshotOptions.text, fontWeight = gifshotOptions.fontWeight, fontSize = utils.getFontSize(gifshotOptions), fontFamily = gifshotOptions.fontFamily, fontColor = gifshotOptions.fontColor, textAlign = gifshotOptions.textAlign, textBaseline = gifshotOptions.textBaseline, textXCoordinate = gifshotOptions.textXCoordinate ? gifshotOptions.textXCoordinate : textAlign === 'left' ? 1 : textAlign === 'right' ? width : width / 2, textYCoordinate = gifshotOptions.textYCoordinate ? gifshotOptions.textYCoordinate : textBaseline === 'top' ? 1 : textBaseline === 'center' ? height / 2 : height, font = fontWeight + ' ' + fontSize + ' ' + fontFamily, imageData, stroke;
- try {
- ctx.drawImage(element, 0, 0, width, height);
- if (text || frameText) {
- ctx.font = font;
- ctx.fillStyle = fontColor;
- ctx.textAlign = textAlign;
- ctx.textBaseline = textBaseline;
- if (gifshotOptions.stroke && frameText) {
- stroke = gifshotOptions.stroke;
- ctx.strokeStyle = stroke.color;
- ctx.lineWidth = stroke.pixels * 2;
- ctx.strokeText(frameText, textXCoordinate, textYCoordinate);
- }
- if (frameText) {
- ctx.fillText(frameText, textXCoordinate, textYCoordinate);
- } else {
- ctx.fillText(text, textXCoordinate, textYCoordinate);
- }
- }
- imageData = ctx.getImageData(0, 0, width, height);
- self.addFrameImageData(imageData);
- } catch (e) {
- return '' + e;
- }
- },
- 'addFrameImageData': function (imageData) {
- var frames = this.frames, imageDataArray = imageData.data;
- this.frames.push({
- 'data': imageDataArray,
- 'width': imageData.width,
- 'height': imageData.height,
- 'palette': null,
- 'dithering': null,
- 'done': false,
- 'beingProcessed': false,
- 'position': frames.length
- });
- },
- 'onRenderProgress': function (callback) {
- this.onRenderProgressCallback = callback;
- },
- 'isRendering': function () {
- return this.generatingGIF;
- },
- 'getBase64GIF': function (completeCallback) {
- var self = this, onRenderComplete = function (gif) {
- self.destroyWorkers();
- utils.requestTimeout(function () {
- completeCallback(gif);
- }, 0);
- };
- self.startRendering(onRenderComplete);
- },
- 'destroyWorkers': function () {
- if (this.workerError) {
- return;
- }
- var workers = this.workers;
- utils.each(workers, function (iterator, workerObj) {
- var worker = workerObj.worker, objectUrl = workerObj.objectUrl;
- worker.terminate();
- utils.URL.revokeObjectURL(objectUrl);
- });
- }
- };
- return AnimatedGIF;
-}(utils, processFrameWorker, NeuQuant, gifWriter);
-getBase64GIF = function getBase64GIF(animatedGifInstance, callback) {
- animatedGifInstance.getBase64GIF(function (image) {
- callback({
- 'error': false,
- 'errorCode': '',
- 'errorMsg': '',
- 'image': image
- });
- });
-};
-existingImages = function (obj) {
- var images = obj.images, imagesLength = obj.imagesLength, callback = obj.callback, options = obj.options, skipObj = {
- 'getUserMedia': true,
- 'window.URL': true
- }, errorObj = error.validate(skipObj), loadedImages = [], loadedImagesLength = 0, tempImage, self = this, ag;
- if (errorObj.error) {
- return callback(errorObj);
- }
- ag = new AnimatedGIF(options);
- utils.each(images, function (index, image) {
- var currentImage = image;
- if (image.src) {
- currentImage = currentImage.src;
- }
- if (utils.isElement(currentImage)) {
- if (options.crossOrigin) {
- currentImage.crossOrigin = options.crossOrigin;
- }
- loadedImages[index] = currentImage;
- loadedImagesLength += 1;
- if (loadedImagesLength === imagesLength) {
- addLoadedImagesToGif();
- }
- } else if (utils.isString(currentImage)) {
- tempImage = new Image();
- if (options.crossOrigin) {
- tempImage.crossOrigin = options.crossOrigin;
- }
- (function (tempImage) {
- if (image.text) {
- tempImage.text = image.text;
- }
- tempImage.onerror = function (e) {
- var error;
- --imagesLength;
- if (imagesLength === 0) {
- error = {};
- error.error = 'None of the requested images was capable of being retrieved';
- return callback(error);
- }
- if (loadedImagesLength === imagesLength) {
- if (obj.options.pause) {
- addPauseFrames(obj.options);
- }
- addLoadedImagesToGif();
- }
- };
- tempImage.onload = function (e) {
- if (image.text) {
- loadedImages[index] = {
- img: tempImage,
- text: tempImage.text
- };
- } else {
- loadedImages[index] = tempImage;
- }
- loadedImagesLength += 1;
- if (loadedImagesLength === imagesLength) {
- if (obj.options.pause) {
- addPauseFrames(obj.options);
- }
- addLoadedImagesToGif();
- }
- utils.removeElement(tempImage);
- };
- tempImage.src = currentImage;
- }(tempImage));
- utils.setCSSAttr(tempImage, {
- 'position': 'fixed',
- 'opacity': '0'
- });
- document.body.appendChild(tempImage);
- }
- });
- function addPauseFrames(options) {
- var speed = 1 / options.interval;
- var len = speed * options.pause;
- var lastImage = loadedImages[loadedImages.length - 1];
- for (var i = 0; i < len; i++) {
- loadedImages.push(lastImage);
- }
- }
- function addLoadedImagesToGif() {
- utils.each(loadedImages, function (index, loadedImage) {
- if (loadedImage) {
- if (loadedImage.text) {
- ag.addFrame(loadedImage.img, options, loadedImage.text);
- } else {
- ag.addFrame(loadedImage, options);
- }
- }
- });
- getBase64GIF(ag, callback);
- }
-};
-screenShot = {
- getGIF: function (options, callback) {
- callback = utils.isFunction(callback) ? callback : utils.noop;
- var canvas = document.createElement('canvas'), context, existingImages = options.images, hasExistingImages = !!existingImages.length, videoElement = options.videoElement, keepCameraOn = options.keepCameraOn, webcamVideoElement = options.webcamVideoElement, cameraStream = options.cameraStream, gifWidth = +options.gifWidth, gifHeight = +options.gifHeight, videoWidth = options.videoWidth, videoHeight = options.videoHeight, sampleInterval = +options.sampleInterval, numWorkers = +options.numWorkers, crop = options.crop, interval = +options.interval, waitBetweenFrames = hasExistingImages ? 0 : interval * 1000, progressCallback = options.progressCallback, savedRenderingContexts = options.savedRenderingContexts, saveRenderingContexts = options.saveRenderingContexts, renderingContextsToSave = [], numFrames = savedRenderingContexts.length ? savedRenderingContexts.length : options.numFrames, pendingFrames = numFrames, ag = new AnimatedGIF(options), text = options.text, fontWeight = options.fontWeight, fontSize = utils.getFontSize(options), fontFamily = options.fontFamily, fontColor = options.fontColor, textAlign = options.textAlign, textBaseline = options.textBaseline, textXCoordinate = options.textXCoordinate ? options.textXCoordinate : textAlign === 'left' ? 1 : textAlign === 'right' ? gifWidth : gifWidth / 2, textYCoordinate = options.textYCoordinate ? options.textYCoordinate : textBaseline === 'top' ? 1 : textBaseline === 'center' ? gifHeight / 2 : gifHeight, font = fontWeight + ' ' + fontSize + ' ' + fontFamily, sourceX = crop ? Math.floor(crop.scaledWidth / 2) : 0, sourceWidth = crop ? videoWidth - crop.scaledWidth : 0, sourceY = crop ? Math.floor(crop.scaledHeight / 2) : 0, sourceHeight = crop ? videoHeight - crop.scaledHeight : 0, captureFrames = function captureFrame() {
- var framesLeft = pendingFrames - 1;
- if (savedRenderingContexts.length) {
- context.putImageData(savedRenderingContexts[numFrames - pendingFrames], 0, 0);
- finishCapture();
- } else {
- drawVideo();
- }
- function drawVideo() {
- try {
- if (sourceWidth > videoWidth) {
- sourceWidth = videoWidth;
- }
- if (sourceHeight > videoHeight) {
- sourceHeight = videoHeight;
- }
- if (sourceX < 0) {
- sourceX = 0;
- }
- if (sourceY < 0) {
- sourceY = 0;
- }
- context.drawImage(videoElement, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, gifWidth, gifHeight);
- finishCapture();
- } catch (e) {
- if (e.name === 'NS_ERROR_NOT_AVAILABLE') {
- utils.requestTimeout(drawVideo, 100);
- } else {
- throw e;
- }
- }
- }
- function finishCapture() {
- pendingFrames = framesLeft;
- var processedFrames = numFrames - pendingFrames;
- var imageData;
- var data;
- var rgba;
- var isBlackFrame;
- if (saveRenderingContexts) {
- renderingContextsToSave.push(context.getImageData(0, 0, gifWidth, gifHeight));
- }
- if (text) {
- context.font = font;
- context.fillStyle = fontColor;
- context.textAlign = textAlign;
- context.textBaseline = textBaseline;
- context.fillText(text, textXCoordinate, textYCoordinate);
- }
- imageData = context.getImageData(0, 0, gifWidth, gifHeight);
- data = imageData.data;
- rgba = data[0] + data[1] + data[2] + data[3];
- isBlackFrame = rgba === 0;
- if (!isBlackFrame) {
- ag.addFrameImageData(imageData);
- } else if (processedFrames === 1 && numFrames === 1) {
- drawVideo();
- }
- progressCallback(processedFrames / numFrames);
- if (framesLeft > 0) {
- utils.requestTimeout(captureFrame, waitBetweenFrames);
- }
- if (!pendingFrames) {
- ag.getBase64GIF(function (image) {
- callback({
- 'error': false,
- 'errorCode': '',
- 'errorMsg': '',
- 'image': image,
- 'cameraStream': cameraStream,
- 'videoElement': videoElement,
- 'webcamVideoElement': webcamVideoElement,
- 'savedRenderingContexts': renderingContextsToSave,
- 'keepCameraOn': keepCameraOn
- });
- });
- }
- }
- };
- numFrames = numFrames != null ? numFrames : 10;
- interval = interval != null ? interval : 0.1;
- canvas.width = gifWidth;
- canvas.height = gifHeight;
- context = canvas.getContext('2d');
- (function capture() {
- if (!savedRenderingContexts.length && videoElement.currentTime === 0) {
- utils.requestTimeout(capture, 100);
- return;
- }
- captureFrames();
- }());
- },
- 'getCropDimensions': function (obj) {
- var width = obj.videoWidth, height = obj.videoHeight, gifWidth = obj.gifWidth, gifHeight = obj.gifHeight, result = {
- width: 0,
- height: 0,
- scaledWidth: 0,
- scaledHeight: 0
- };
- if (width > height) {
- result.width = Math.round(width * (gifHeight / height)) - gifWidth;
- result.scaledWidth = Math.round(result.width * (height / gifHeight));
- } else {
- result.height = Math.round(height * (gifWidth / width)) - gifHeight;
- result.scaledHeight = Math.round(result.height * (width / gifWidth));
- }
- return result;
- }
-};
-videoStream = {
- 'loadedData': false,
- 'defaultVideoDimensions': {
- 'width': 640,
- 'height': 480
- },
- 'findVideoSize': function findVideoSizeMethod(obj) {
- findVideoSizeMethod.attempts = findVideoSizeMethod.attempts || 0;
- var self = this, videoElement = obj.videoElement, cameraStream = obj.cameraStream, completedCallback = obj.completedCallback;
- if (!videoElement) {
- return;
- }
- if (videoElement.videoWidth > 0 && videoElement.videoHeight > 0) {
- videoElement.removeEventListener('loadeddata', self.findVideoSize);
- completedCallback({
- 'videoElement': videoElement,
- 'cameraStream': cameraStream,
- 'videoWidth': videoElement.videoWidth,
- 'videoHeight': videoElement.videoHeight
- });
- } else {
- if (findVideoSizeMethod.attempts < 10) {
- findVideoSizeMethod.attempts += 1;
- utils.requestTimeout(function () {
- self.findVideoSize(obj);
- }, 200);
- } else {
- completedCallback({
- 'videoElement': videoElement,
- 'cameraStream': cameraStream,
- 'videoWidth': self.defaultVideoDimensions.width,
- 'videoHeight': self.defaultVideoDimensions.height
- });
- }
- }
- },
- 'onStreamingTimeout': function (callback) {
- if (utils.isFunction(callback)) {
- callback({
- 'error': true,
- 'errorCode': 'getUserMedia',
- 'errorMsg': 'There was an issue with the getUserMedia API - Timed out while trying to start streaming',
- 'image': null,
- 'cameraStream': {}
- });
- }
- },
- 'stream': function (obj) {
- var self = this, existingVideo = utils.isArray(obj.existingVideo) ? obj.existingVideo[0] : obj.existingVideo, videoElement = obj.videoElement, cameraStream = obj.cameraStream, streamedCallback = obj.streamedCallback, completedCallback = obj.completedCallback;
- if (utils.isFunction(streamedCallback)) {
- streamedCallback();
- }
- if (existingVideo) {
- if (utils.isString(existingVideo)) {
- videoElement.src = existingVideo;
- videoElement.innerHTML = '<source src="' + existingVideo + '" type="video/' + utils.getExtension(existingVideo) + '" />';
- }
- } else if (videoElement.mozSrcObject) {
- videoElement.mozSrcObject = cameraStream;
- } else if (utils.URL) {
- videoElement.src = utils.URL.createObjectURL(cameraStream);
- }
- videoElement.play();
- utils.requestTimeout(function checkLoadedData() {
- checkLoadedData.count = checkLoadedData.count || 0;
- if (self.loadedData === true) {
- self.findVideoSize({
- 'videoElement': videoElement,
- 'cameraStream': cameraStream,
- 'completedCallback': completedCallback
- });
- self.loadedData = false;
- } else {
- checkLoadedData.count += 1;
- if (checkLoadedData.count > 10) {
- self.findVideoSize({
- 'videoElement': videoElement,
- 'cameraStream': cameraStream,
- 'completedCallback': completedCallback
- });
- } else {
- checkLoadedData();
- }
- }
- }, 100);
- },
- 'startStreaming': function (obj) {
- var self = this, errorCallback = utils.isFunction(obj.error) ? obj.error : utils.noop, streamedCallback = utils.isFunction(obj.streamed) ? obj.streamed : utils.noop, completedCallback = utils.isFunction(obj.completed) ? obj.completed : utils.noop, existingVideo = obj.existingVideo, webcamVideoElement = obj.webcamVideoElement, videoElement = utils.isElement(existingVideo) ? existingVideo : webcamVideoElement ? webcamVideoElement : document.createElement('video'), lastCameraStream = obj.lastCameraStream, crossOrigin = obj.crossOrigin, options = obj.options, cameraStream;
- if (crossOrigin) {
- videoElement.crossOrigin = options.crossOrigin;
- }
- videoElement.autoplay = true;
- videoElement.loop = true;
- videoElement.muted = true;
- videoElement.addEventListener('loadeddata', function (event) {
- self.loadedData = true;
- });
- if (existingVideo) {
- self.stream({
- 'videoElement': videoElement,
- 'existingVideo': existingVideo,
- 'completedCallback': completedCallback
- });
- } else if (lastCameraStream) {
- self.stream({
- 'videoElement': videoElement,
- 'cameraStream': lastCameraStream,
- 'streamedCallback': streamedCallback,
- 'completedCallback': completedCallback
- });
- } else {
- utils.getUserMedia({ 'video': true }, function (stream) {
- self.stream({
- 'videoElement': videoElement,
- 'cameraStream': stream,
- 'streamedCallback': streamedCallback,
- 'completedCallback': completedCallback
- });
- }, errorCallback);
- }
- },
- startVideoStreaming: function (callback, options) {
- options = options || {};
- var self = this, noGetUserMediaSupportTimeout, timeoutLength = options.timeout !== undefined ? options.timeout : 0, originalCallback = options.callback, webcamVideoElement = options.webcamVideoElement;
- if (timeoutLength > 0) {
- noGetUserMediaSupportTimeout = utils.requestTimeout(function () {
- self.onStreamingTimeout(originalCallback);
- }, 10000);
- }
- this.startStreaming({
- 'error': function () {
- originalCallback({
- 'error': true,
- 'errorCode': 'getUserMedia',
- 'errorMsg': 'There was an issue with the getUserMedia API - the user probably denied permission',
- 'image': null,
- 'cameraStream': {}
- });
- },
- 'streamed': function () {
- clearTimeout(noGetUserMediaSupportTimeout);
- },
- 'completed': function (obj) {
- var cameraStream = obj.cameraStream, videoElement = obj.videoElement, videoWidth = obj.videoWidth, videoHeight = obj.videoHeight;
- callback({
- 'cameraStream': cameraStream,
- 'videoElement': videoElement,
- 'videoWidth': videoWidth,
- 'videoHeight': videoHeight
- });
- },
- 'lastCameraStream': options.lastCameraStream,
- 'webcamVideoElement': webcamVideoElement,
- 'crossOrigin': options.crossOrigin,
- 'options': options
- });
- },
- 'stopVideoStreaming': function (obj) {
- obj = utils.isObject(obj) ? obj : {};
- var cameraStream = obj.cameraStream, videoElement = obj.videoElement, keepCameraOn = obj.keepCameraOn, webcamVideoElement = obj.webcamVideoElement;
- if (!keepCameraOn && cameraStream && utils.isFunction(cameraStream.stop)) {
- cameraStream.stop();
- }
- if (utils.isElement(videoElement) && !webcamVideoElement) {
- videoElement.pause();
- if (utils.isFunction(utils.URL.revokeObjectURL) && !utils.webWorkerError) {
- if (videoElement.src) {
- utils.URL.revokeObjectURL(videoElement.src);
- }
- }
- utils.removeElement(videoElement);
- }
- }
-};
-stopVideoStreaming = function (obj) {
- obj = utils.isObject(obj) ? obj : {};
- var options = utils.isObject(obj.options) ? obj.options : {}, cameraStream = obj.cameraStream, videoElement = obj.videoElement, webcamVideoElement = obj.webcamVideoElement, keepCameraOn = obj.keepCameraOn;
- videoStream.stopVideoStreaming({
- 'cameraStream': cameraStream,
- 'videoElement': videoElement,
- 'keepCameraOn': keepCameraOn,
- 'webcamVideoElement': webcamVideoElement
- });
-};
-createAndGetGIF = function (obj, callback) {
- var options = obj.options || {}, images = options.images, video = options.video, numFrames = +options.numFrames, cameraStream = obj.cameraStream, videoElement = obj.videoElement, videoWidth = obj.videoWidth, videoHeight = obj.videoHeight, gifWidth = +options.gifWidth, gifHeight = +options.gifHeight, cropDimensions = screenShot.getCropDimensions({
- 'videoWidth': videoWidth,
- 'videoHeight': videoHeight,
- 'gifHeight': gifHeight,
- 'gifWidth': gifWidth
- }), completeCallback = callback;
- options.crop = cropDimensions;
- options.videoElement = videoElement;
- options.videoWidth = videoWidth;
- options.videoHeight = videoHeight;
- options.cameraStream = cameraStream;
- if (!utils.isElement(videoElement)) {
- return;
- }
- videoElement.width = gifWidth + cropDimensions.width;
- videoElement.height = gifHeight + cropDimensions.height;
- if (!options.webcamVideoElement) {
- utils.setCSSAttr(videoElement, {
- 'position': 'fixed',
- 'opacity': '0'
- });
- document.body.appendChild(videoElement);
- }
- videoElement.play();
- screenShot.getGIF(options, function (obj) {
- if ((!images || !images.length) && (!video || !video.length)) {
- stopVideoStreaming(obj);
- }
- completeCallback(obj);
- });
-};
-existingVideo = function (obj) {
- var existingVideo = obj.existingVideo, callback = obj.callback, options = obj.options, skipObj = {
- 'getUserMedia': true,
- 'window.URL': true
- }, errorObj = error.validate(skipObj), loadedImages = 0, videoType, videoSrc, tempImage, ag;
- if (errorObj.error) {
- return callback(errorObj);
- }
- if (utils.isElement(existingVideo) && existingVideo.src) {
- videoSrc = existingVideo.src;
- videoType = utils.getExtension(videoSrc);
- if (!utils.isSupported.videoCodecs[videoType]) {
- return callback(error.messages.videoCodecs);
- }
- } else if (utils.isArray(existingVideo)) {
- utils.each(existingVideo, function (iterator, videoSrc) {
- videoType = videoSrc.substr(videoSrc.lastIndexOf('.') + 1, videoSrc.length);
- if (utils.isSupported.videoCodecs[videoType]) {
- existingVideo = videoSrc;
- return false;
- }
- });
- }
- videoStream.startStreaming({
- 'completed': function (obj) {
- obj.options = options || {};
- createAndGetGIF(obj, callback);
- },
- 'existingVideo': existingVideo,
- 'crossOrigin': options.crossOrigin,
- 'options': options
- });
-};
-existingWebcam = function (obj) {
- var lastCameraStream = obj.lastCameraStream, callback = obj.callback, webcamVideoElement = obj.webcamVideoElement, options = obj.options;
- if (!isWebCamGIFSupported()) {
- return callback(error.validate());
- }
- if (options.savedRenderingContexts.length) {
- screenShot.getWebcamGIF(options, function (obj) {
- callback(obj);
- });
- return;
- }
- videoStream.startVideoStreaming(function (obj) {
- obj.options = options || {};
- createAndGetGIF(obj, callback);
- }, {
- 'lastCameraStream': lastCameraStream,
- 'callback': callback,
- 'webcamVideoElement': webcamVideoElement,
- 'crossOrigin': options.crossOrigin
- });
-};
-createGIF = function (userOptions, callback) {
- callback = utils.isFunction(userOptions) ? userOptions : callback;
- userOptions = utils.isObject(userOptions) ? userOptions : {};
- if (!utils.isFunction(callback)) {
- return;
- }
- var options = utils.mergeOptions(defaultOptions, userOptions) || {}, lastCameraStream = userOptions.cameraStream, images = options.images, imagesLength = images ? images.length : 0, video = options.video, webcamVideoElement = options.webcamVideoElement;
- options = utils.mergeOptions(options, {
- 'gifWidth': Math.floor(options.gifWidth),
- 'gifHeight': Math.floor(options.gifHeight)
- });
- if (imagesLength) {
- existingImages({
- 'images': images,
- 'imagesLength': imagesLength,
- 'callback': callback,
- 'options': options
- });
- } else if (video) {
- existingVideo({
- 'existingVideo': video,
- 'callback': callback,
- 'options': options
- });
- } else {
- existingWebcam({
- 'lastCameraStream': lastCameraStream,
- 'callback': callback,
- 'webcamVideoElement': webcamVideoElement,
- 'options': options
- });
- }
-};
-takeSnapShot = function (userOptions, callback) {
- callback = utils.isFunction(userOptions) ? userOptions : callback;
- userOptions = utils.isObject(userOptions) ? userOptions : {};
- if (!utils.isFunction(callback)) {
- return;
- }
- var mergedOptions = utils.mergeOptions(defaultOptions, userOptions), options = utils.mergeOptions(mergedOptions, {
- 'interval': 0.1,
- 'numFrames': 1,
- 'gifWidth': Math.floor(mergedOptions.gifWidth),
- 'gifHeight': Math.floor(mergedOptions.gifHeight)
- });
- createGIF(options, callback);
-};
-API = function (utils, error, defaultOptions, isSupported, isWebCamGIFSupported, isExistingImagesGIFSupported, isExistingVideoGIFSupported, createGIF, takeSnapShot, stopVideoStreaming) {
- var gifshot = {
- 'utils': utils,
- 'error': error,
- 'defaultOptions': defaultOptions,
- 'createGIF': createGIF,
- 'takeSnapShot': takeSnapShot,
- 'stopVideoStreaming': stopVideoStreaming,
- 'isSupported': isSupported,
- 'isWebCamGIFSupported': isWebCamGIFSupported,
- 'isExistingVideoGIFSupported': isExistingVideoGIFSupported,
- 'isExistingImagesGIFSupported': isExistingImagesGIFSupported,
- 'VERSION': '0.3.2'
- };
- return gifshot;
-}(utils, error, defaultOptions, isSupported, isWebCamGIFSupported, isExistingImagesGIFSupported, isExistingVideoGIFSupported, createGIF, takeSnapShot, stopVideoStreaming);
-(function (API) {
- if (typeof define === 'function' && define.amd) {
- define([], function () {
- return API;
- });
- } else if (typeof exports !== 'undefined') {
- module.exports = API;
- } else {
- window.gifshot = API;
- }
-}(API));
-}(typeof window !== "undefined" ? window : {}, typeof document !== "undefined" ? document : { createElement: function() {} }, typeof window !== "undefined" ? window.navigator : {}));
\ No newline at end of file
diff --git a/web/ext/anim/gifshot/gifshot.min.js b/web/ext/anim/gifshot/gifshot.min.js
deleted file mode 100644
index d308c4196..000000000
--- a/web/ext/anim/gifshot/gifshot.min.js
+++ /dev/null
@@ -1,8 +0,0 @@
-/*Copyrights for code authored by Yahoo Inc. is licensed under the following terms:
-MIT License
-Copyright 2015 Yahoo Inc.
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-!function(e,t,r,i){var n,o,a,s,d,c,l,u,m,f,g,h,p,v,b,w,y,C,S,k,x,F;n=function(){var i={URL:e.URL||e.webkitURL||e.mozURL||e.msURL,getUserMedia:function(){var e=r.getUserMedia||r.webkitGetUserMedia||r.mozGetUserMedia||r.msGetUserMedia;return e?e.bind(r):e}(),requestAnimFrame:e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame,requestTimeout:function(e,t){function r(){var i=(new Date).getTime(),s=i-n;s>=t?e.call():o.value=a(r)}if(e=e||i.noop,t=t||0,!i.requestAnimFrame)return setTimeout(e,t);var n=(new Date).getTime(),o=new Object,a=i.requestAnimFrame;return o.value=a(r),o},Blob:e.Blob||e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||e.MSBlobBuilder,btoa:function(){var t=e.btoa||function(e){for(var t,r,i,n,o,a,s,d="",c=0,l=e.length,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";l>c;)t=e.charCodeAt(c++),r=e.charCodeAt(c++),i=e.charCodeAt(c++),n=t>>2,o=(3&t)<<4|r>>4,a=(15&r)<<2|i>>6,s=63&i,isNaN(r)?a=s=64:isNaN(i)&&(s=64),d=d+u.charAt(n)+u.charAt(o)+u.charAt(a)+u.charAt(s);return d};return t?t.bind(e):function(){}}(),isObject:function(e){return e&&"[object Object]"===Object.prototype.toString.call(e)},isEmptyObject:function(e){return i.isObject(e)&&!Object.keys(e).length},isArray:function(e){return e&&Array.isArray(e)},isFunction:function(e){return e&&"function"==typeof e},isElement:function(e){return e&&1===e.nodeType},isString:function(e){return"string"==typeof e||"[object String]"===Object.prototype.toString.call(e)},isSupported:{canvas:function(){var e=t.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return e.Worker},blob:function(){return i.Blob},Uint8Array:function(){return e.Uint8Array},Uint32Array:function(){return e.Uint32Array},videoCodecs:function(){var e=t.createElement("video"),r={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{e&&e.canPlayType&&(r.mp4=""!==e.canPlayType('video/mp4; codecs="mp4v.20.8"'),r.h264=""!==(e.canPlayType('video/mp4; codecs="avc1.42E01E"')||e.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')),r.ogv=""!==e.canPlayType('video/ogg; codecs="theora"'),r.ogg=""!==e.canPlayType('video/ogg; codecs="theora"'),r.webm=-1!==e.canPlayType('video/webm; codecs="vp8, vorbis"'))}catch(i){}return r}()},noop:function(){},each:function(e,t){var r,n;if(i.isArray(e))for(r=-1,n=e.length;++r<n&&t(r,e[r])!==!1;);else if(i.isObject(e))for(r in e)if(e.hasOwnProperty(r)&&t(r,e[r])===!1)break},mergeOptions:function n(e,t){if(i.isObject(e)&&i.isObject(t)&&Object.keys){var r={};return i.each(e,function(t){r[t]=e[t]}),i.each(t,function(o){var a=t[o];r[o]=i.isObject(a)?e[o]?n(e[o],a):a:a}),r}},setCSSAttr:function(e,t,r){i.isElement(e)&&(i.isString(t)&&i.isString(r)?e.style[t]=r:i.isObject(t)&&i.each(t,function(t,r){e.style[t]=r}))},removeElement:function(e){i.isElement(e)&&e.parentNode&&e.parentNode.removeChild(e)},createWebWorker:function(e){if(!i.isString(e))return{};try{var t=new i.Blob([e],{type:"text/javascript"}),r=i.URL.createObjectURL(t),n=new Worker(r);return{objectUrl:r,worker:n}}catch(o){return""+o}},getExtension:function(e){return e.substr(e.lastIndexOf(".")+1,e.length)},getFontSize:function(e){if(e=e||{},!t.body||e.resizeFont===!1)return e.fontSize;var r=e.text,i=e.gifWidth,n=parseInt(e.fontSize,10),o=parseInt(e.minFontSize,10),a=t.createElement("div"),s=t.createElement("span");for(a.setAttribute("width",i),a.appendChild(s),s.innerHTML=r,s.style.fontSize=n+"px",s.style.textIndent="-9999px",s.style.visibility="hidden",t.body.appendChild(s);s.offsetWidth>i&&n>=o;)s.style.fontSize=--n+"px";return t.body.removeChild(s),n+"px"},webWorkerError:!1};return i}(),o=function(e){var t={validate:function(r){r=e.isObject(r)?r:{};var i={};return e.each(t.validators,function(e,t){var n=t.errorCode;return r[n]||t.condition?void 0:(i=t,i.error=!0,!1)}),delete i.condition,i},isValid:function(e){var r=t.validate(e),i=r.error!==!0?!0:!1;return i},validators:[{condition:e.isFunction(e.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:e.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:e.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:e.isFunction(e.URL),errorCode:"window.URL",errorMsg:"The window.URL API is not supported in your browser"},{condition:e.isSupported.blob(),errorCode:"window.Blob",errorMsg:"The window.Blob File API is not supported in your browser"},{condition:e.isSupported.Uint8Array(),errorCode:"window.Uint8Array",errorMsg:"The window.Uint8Array function constructor is not supported in your browser"},{condition:e.isSupported.Uint32Array(),errorCode:"window.Uint32Array",errorMsg:"The window.Uint32Array function constructor is not supported in your browser"}],messages:{videoCodecs:{errorCode:"videocodec",errorMsg:"The video codec you are trying to use is not supported in your browser"}}};return t}(n),a={sampleInterval:10,numWorkers:2,gifWidth:200,gifHeight:200,interval:.1,numFrames:10,keepCameraOn:!1,images:[],video:null,webcamVideoElement:null,cameraStream:null,text:"",fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,progressCallback:function(){},completeCallback:function(){},saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},s=function(){return o.isValid()},d=function(){return o.isValid()},c=function(){var e={getUserMedia:!0};return o.isValid(e)},l=function(e){var t=!1;if(n.isArray(e)&&e.length){if(n.each(e,function(e,r){n.isSupported.videoCodecs[r]&&(t=!0)}),!t)return!1}else if(n.isString(e)&&e.length&&!n.isSupported.videoCodecs[e])return!1;return o.isValid({getUserMedia:!0})},u=function(){function e(){function e(e,t,r){var i,n;for(u=e,m=t,f=r,g=new Array(h),i=0;h>i;i++)g[i]=new Array(4),n=g[i],n[0]=n[1]=n[2]=(i<<S+8)/h|0,D[i]=F/h|0,G[i]=0}function t(){for(var e=[],t=new Array(h),r=0;h>r;r++)t[g[r][3]]=r;for(var i=0,n=0;h>n;n++){var o=t[n];e[i++]=g[o][0],e[i++]=g[o][1],e[i++]=g[o][2]}return e}function r(){var e,t,r,i,n,o,a,s;for(a=0,s=0,e=0;h>e;e++){for(n=g[e],r=e,i=n[1],t=e+1;h>t;t++)o=g[t],o[1]<i&&(r=t,i=o[1]);if(o=g[r],e!=r&&(t=o[0],o[0]=n[0],n[0]=t,t=o[1],o[1]=n[1],n[1]=t,t=o[2],o[2]=n[2],n[2]=t,t=o[3],o[3]=n[3],n[3]=t),i!=a){for(B[a]=s+e>>1,t=a+1;i>t;t++)B[t]=e;a=i,s=e}}for(B[a]=s+C>>1,t=a+1;256>t;t++)B[t]=C}function i(){var e,t,r,i,n,o,a,g,h,C,x,F,E,W;for(y>m&&(f=1),l=30+(f-1)/3,F=u,E=0,W=m,x=m/(3*f),C=x/k|0,g=j,o=I,a=o>>R,1>=a&&(a=0),e=0;a>e;e++)q[e]=g*((a*a-e*e)*z/(a*a));for(h=y>m?3:m%p!==0?3*p:m%v!==0?3*v:m%b!==0?3*b:3*w,e=0;x>e;)if(r=(255&F[E+0])<<S,i=(255&F[E+1])<<S,n=(255&F[E+2])<<S,t=c(r,i,n),d(g,t,r,i,n),0!==a&&s(a,t,r,i,n),E+=h,E>=W&&(E-=m),e++,0===C&&(C=1),e%C===0)for(g-=g/l,o-=o/T,a=o>>R,1>=a&&(a=0),t=0;a>t;t++)q[t]=g*((a*a-t*t)*z/(a*a))}function n(e,t,r){var i,n,o,a,s,d,c;for(s=1e3,c=-1,i=B[t],n=i-1;h>i||n>=0;)h>i&&(d=g[i],o=d[1]-t,o>=s?i=h:(i++,0>o&&(o=-o),a=d[0]-e,0>a&&(a=-a),o+=a,s>o&&(a=d[2]-r,0>a&&(a=-a),o+=a,s>o&&(s=o,c=d[3])))),n>=0&&(d=g[n],o=t-d[1],o>=s?n=-1:(n--,0>o&&(o=-o),a=d[0]-e,0>a&&(a=-a),o+=a,s>o&&(a=d[2]-r,0>a&&(a=-a),o+=a,s>o&&(s=o,c=d[3]))));return c}function o(){return i(),a(),r(),t()}function a(){var e;for(e=0;h>e;e++)g[e][0]>>=S,g[e][1]>>=S,g[e][2]>>=S,g[e][3]=e}function s(e,t,r,i,n){var o,a,s,d,c,l,u;for(s=t-e,-1>s&&(s=-1),d=t+e,d>h&&(d=h),o=t+1,a=t-1,l=1;d>o||a>s;){if(c=q[l++],d>o){u=g[o++];try{u[0]-=c*(u[0]-r)/P|0,u[1]-=c*(u[1]-i)/P|0,u[2]-=c*(u[2]-n)/P|0}catch(m){}}if(a>s){u=g[a--];try{u[0]-=c*(u[0]-r)/P|0,u[1]-=c*(u[1]-i)/P|0,u[2]-=c*(u[2]-n)/P|0}catch(m){}}}}function d(e,t,r,i,n){var o=g[t],a=e/j;o[0]-=a*(o[0]-r)|0,o[1]-=a*(o[1]-i)|0,o[2]-=a*(o[2]-n)|0}function c(e,t,r){var i,n,o,a,s,d,c,l,u,m;for(l=~(1<<31),u=l,d=-1,c=d,i=0;h>i;i++)m=g[i],n=m[0]-e,0>n&&(n=-n),o=m[1]-t,0>o&&(o=-o),n+=o,o=m[2]-r,0>o&&(o=-o),n+=o,l>n&&(l=n,d=i),a=n-(G[i]>>x-S),u>a&&(u=a,c=i),s=D[i]>>W,D[i]-=s,G[i]+=s<<E;return D[d]+=O,G[d]-=A,c}var l,u,m,f,g,h=256,p=499,v=491,b=487,w=503,y=3*w,C=h-1,S=4,k=100,x=16,F=1<<x,E=10,W=10,O=F>>W,A=F<<E-W,U=h>>3,R=6,M=1<<R,I=U*M,T=30,V=10,j=1<<V,H=8,z=1<<H,L=V+H,P=1<<L,B=[],G=[],D=[],q=[];e.apply(this,arguments);var N={};return N.map=n,N.process=o,N}return e}(),m=function(e){var t=function(){try{self.onmessage=function(e){var t,i=e.data||{};i.gifshot&&(t=r.run(i),postMessage(t))}}catch(t){}var r={dataToRGB:function(e,t,r){for(var i=0,n=t*r*4,o=[];n>i;)o.push(e[i++]),o.push(e[i++]),o.push(e[i++]),i++;return o},componentizedPaletteToArray:function(e){var t,r,i,n,o=[];for(t=0;t<e.length;t+=3)r=e[t],i=e[t+1],n=e[t+2],o.push(r<<16|i<<8|n);return o},processFrameWithQuantizer:function(t,r,i,n){var o,a,s,d,c=this.dataToRGB(t,r,i),l=new e(c,c.length,n),u=l.process(),m=new Uint32Array(this.componentizedPaletteToArray(u)),f=r*i,g=new Uint8Array(f),h=0;for(o=0;f>o;o++)a=c[h++],s=c[h++],d=c[h++],g[o]=l.map(a,s,d);return{pixels:g,palette:m}},run:function(e){var t=e.width,r=e.height,i=e.data,n=(e.palette,e.sampleInterval);return this.processFrameWithQuantizer(i,t,r,n)}};return r};return t}(u),f=function(e,t,r,n){function o(e){var t=e.length;if(2>t||t>256||t&t-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return t}function a(e,t,r,n){function o(r){for(;f>=r;)e[t++]=255&g,g>>=8,f-=8,t===s+256&&(e[s]=255,s=t++)}function a(e){g|=e<<f,f+=m,o(8)}e[t++]=r;var s=t++,d=1<<r,c=d-1,l=d+1,u=l+1,m=r+1,f=0,g=0,h=n[0]&c,p={};a(d);for(var v=1,b=n.length;b>v;++v){var w=n[v]&c,y=h<<8|w,C=p[y];if(C===i){for(g|=h<<f,f+=m;f>=8;)e[t++]=255&g,g>>=8,f-=8,t===s+256&&(e[s]=255,s=t++);4096===u?(a(d),u=l+1,m=r+1,p={}):(u>=1<<m&&++m,p[y]=u++),h=w}else h=C}return a(h),a(l),o(1),s+1===t?e[s]=0:(e[s]=t-s-1,e[t++]=0),t}var s=0;n=n===i?{}:n;var d=n.loop===i?null:n.loop,c=n.palette===i?null:n.palette;if(0>=t||0>=r||t>65535||r>65535)throw"Width/Height invalid.";e[s++]=71,e[s++]=73,e[s++]=70,e[s++]=56,e[s++]=57,e[s++]=97;var l=0,u=0;if(e[s++]=255&t,e[s++]=t>>8&255,e[s++]=255&r,e[s++]=r>>8&255,e[s++]=(null!==c?128:0)|l,e[s++]=u,e[s++]=0,null!==d){if(0>d||d>65535)throw"Loop count invalid.";e[s++]=33,e[s++]=255,e[s++]=11,e[s++]=78,e[s++]=69,e[s++]=84,e[s++]=83,e[s++]=67,e[s++]=65,e[s++]=80,e[s++]=69,e[s++]=50,e[s++]=46,e[s++]=48,e[s++]=3,e[s++]=1,e[s++]=255&d,e[s++]=d>>8&255,e[s++]=0}var m=!1;this.addFrame=function(t,r,n,d,l,u){if(m===!0&&(--s,m=!1),u=u===i?{}:u,0>t||0>r||t>65535||r>65535)throw"x/y invalid.";if(0>=n||0>=d||n>65535||d>65535)throw"Width/Height invalid.";if(l.length<n*d)throw"Not enough pixels for the frame size.";var f=!0,g=u.palette;if((g===i||null===g)&&(f=!1,g=c),g===i||null===g)throw"Must supply either a local or global palette.";for(var h=o(g),p=0;h>>=1;)++p;h=1<<p;var v=u.delay===i?0:u.delay,b=u.disposal===i?0:u.disposal;if(0>b||b>3)throw"Disposal out of range.";var w=!1,y=0;if(u.transparent!==i&&null!==u.transparent&&(w=!0,y=u.transparent,0>y||y>=h))throw"Transparent color index.";if((0!==b||w||0!==v)&&(e[s++]=33,e[s++]=249,e[s++]=4,e[s++]=b<<2|(w===!0?1:0),e[s++]=255&v,e[s++]=v>>8&255,e[s++]=y,e[s++]=0),e[s++]=44,e[s++]=255&t,e[s++]=t>>8&255,e[s++]=255&r,e[s++]=r>>8&255,e[s++]=255&n,e[s++]=n>>8&255,e[s++]=255&d,e[s++]=d>>8&255,e[s++]=f===!0?128|p-1:0,f===!0)for(var C=0,S=g.length;S>C;++C){var k=g[C];e[s++]=k>>16&255,e[s++]=k>>8&255,e[s++]=255&k}s=a(e,s,2>p?2:p,l)},this.end=function(){return m===!1&&(e[s++]=59,m=!0),s}},g=function(e,r,i,n){var o=function(t){this.canvas=null,this.ctx=null,this.repeat=0,this.frames=[],this.numRenderedFrames=0,this.onRenderCompleteCallback=e.noop,this.onRenderProgressCallback=e.noop,this.workers=[],this.availableWorkers=[],this.generatingGIF=!1,this.options=t,this.initializeWebWorkers(t)};return o.prototype={workerMethods:r(),initializeWebWorkers:function(n){var o,a,s,d,c=i.toString()+"("+r.toString()+"());",l=-1,u="";for(d=n.numWorkers;++l<d;)o=e.createWebWorker(c),e.isObject(o)?(a=o.objectUrl,s=o.worker,this.workers.push({worker:s,objectUrl:a}),this.availableWorkers.push(s)):(u=o,e.webWorkerError=!!o);this.workerError=u,this.canvas=t.createElement("canvas"),this.canvas.width=n.gifWidth,this.canvas.height=n.gifHeight,this.ctx=this.canvas.getContext("2d"),this.frames=[]},getWorker:function(){return this.availableWorkers.pop()},freeWorker:function(e){this.availableWorkers.push(e)},byteMap:function(){for(var e=[],t=0;256>t;t++)e[t]=String.fromCharCode(t);return e}(),bufferToString:function(e){for(var t=e.length,r="",i=-1;++i<t;)r+=this.byteMap[e[i]];return r},onFrameFinished:function(t){var r=this,i=r.frames,n=r.options;hasExistingImages=!!(n.images||[]).length,allDone=i.every(function(e){return!e.beingProcessed&&e.done}),r.numRenderedFrames++,hasExistingImages&&t(r.numRenderedFrames/i.length),r.onRenderProgressCallback(.75*r.numRenderedFrames/i.length),allDone?r.generatingGIF||r.generateGIF(i,r.onRenderCompleteCallback):e.requestTimeout(function(){r.processNextFrame()},1)},processFrame:function(e){var t,r,i=this,n=this.options,o=n.progressCallback,a=n.sampleInterval,s=this.frames,d=function(e){var n=e.data;delete t.data,t.pixels=Array.prototype.slice.call(n.pixels),t.palette=Array.prototype.slice.call(n.palette),t.done=!0,t.beingProcessed=!1,i.freeWorker(r),i.onFrameFinished(o)};return t=s[e],t.beingProcessed||t.done?(this.onFrameFinished(),void 0):(t.sampleInterval=a,t.beingProcessed=!0,t.gifshot=!0,r=this.getWorker(),r?(r.onmessage=d,r.postMessage(t)):d({data:i.workerMethods.run(t)}),void 0)},startRendering:function(e){this.onRenderCompleteCallback=e;for(var t=0;t<this.options.numWorkers&&t<this.frames.length;t++)this.processFrame(t)},processNextFrame:function(){for(var e=-1,t=0;t<this.frames.length;t++){var r=this.frames[t];if(!r.done&&!r.beingProcessed){e=t;break}}e>=0&&this.processFrame(e)},generateGIF:function(t,r){var i,o,a=[],s={loop:this.repeat},d=this.options,c=d.interval,l=d.images,u=!!l.length,m=d.gifHeight,f=d.gifWidth,g=new n(a,f,m,s),h=this.onRenderProgressCallback,p=u?100*c:0;this.generatingGIF=!0,e.each(t,function(e,r){var i=r.palette;h(.75+.25*r.position*1/t.length),g.addFrame(0,0,f,m,r.pixels,{palette:i,delay:p})}),g.end(),h(1),this.frames=[],this.generatingGIF=!1,e.isFunction(r)&&(i=this.bufferToString(a),o="data:image/gif;base64,"+e.btoa(i),r(o))},setRepeat:function(e){this.repeat=e},addFrame:function(t,r,i){r=e.isObject(r)?r:{};var n,o,a=this,s=a.ctx,d=a.options,c=d.gifWidth,l=d.gifHeight,u=(r.gifHeight,r.gifWidth,r.text),m=r.fontWeight,f=e.getFontSize(r),g=r.fontFamily,h=r.fontColor,p=r.textAlign,v=r.textBaseline,b=r.textXCoordinate?r.textXCoordinate:"left"===p?1:"right"===p?c:c/2,w=r.textYCoordinate?r.textYCoordinate:"top"===v?1:"center"===v?l/2:l,y=m+" "+f+" "+g;try{s.drawImage(t,0,0,c,l),(u||i)&&(s.font=y,s.fillStyle=h,s.textAlign=p,s.textBaseline=v,r.stroke&&i&&(o=r.stroke,s.strokeStyle=o.color,s.lineWidth=2*o.pixels,s.strokeText(i,b,w)),i?s.fillText(i,b,w):s.fillText(u,b,w)),n=s.getImageData(0,0,c,l),a.addFrameImageData(n)}catch(C){return""+C}},addFrameImageData:function(e){var t=this.frames,r=e.data;this.frames.push({data:r,width:e.width,height:e.height,palette:null,dithering:null,done:!1,beingProcessed:!1,position:t.length})},onRenderProgress:function(e){this.onRenderProgressCallback=e},isRendering:function(){return this.generatingGIF},getBase64GIF:function(t){var r=this,i=function(i){r.destroyWorkers(),e.requestTimeout(function(){t(i)},0)};r.startRendering(i)},destroyWorkers:function(){if(!this.workerError){var t=this.workers;e.each(t,function(t,r){var i=r.worker,n=r.objectUrl;i.terminate(),e.URL.revokeObjectURL(n)})}}},o}(n,m,u,f),h=function(e,t){e.getBase64GIF(function(e){t({error:!1,errorCode:"",errorMsg:"",image:e})})},p=function(e){function r(e){for(var t=1/e.interval,r=t*e.pause,i=p[p.length-1],n=0;r>n;n++)p.push(i)}function i(){n.each(p,function(e,t){t&&(t.text?s.addFrame(t.img,u,t.text):s.addFrame(t,u))}),h(s,l)}var a,s,d=e.images,c=e.imagesLength,l=e.callback,u=e.options,m={getUserMedia:!0,"window.URL":!0},f=o.validate(m),p=[],v=0;return f.error?l(f):(s=new g(u),n.each(d,function(o,s){var d=s;s.src&&(d=d.src),n.isElement(d)?(u.crossOrigin&&(d.crossOrigin=u.crossOrigin),p[o]=d,v+=1,v===c&&i()):n.isString(d)&&(a=new Image,u.crossOrigin&&(a.crossOrigin=u.crossOrigin),function(t){s.text&&(t.text=s.text),t.onerror=function(){var t;return--c,0===c?(t={},t.error="None of the requested images was capable of being retrieved",l(t)):(v===c&&(e.options.pause&&r(e.options),i()),void 0)},t.onload=function(){p[o]=s.text?{img:t,text:t.text}:t,v+=1,v===c&&(e.options.pause&&r(e.options),i()),n.removeElement(t)},t.src=d}(a),n.setCSSAttr(a,{position:"fixed",opacity:"0"}),t.body.appendChild(a))}),void 0)},v={getGIF:function(e,r){r=n.isFunction(r)?r:n.noop;var i,o=t.createElement("canvas"),a=e.images,s=!!a.length,d=e.videoElement,c=e.keepCameraOn,l=e.webcamVideoElement,u=e.cameraStream,m=+e.gifWidth,f=+e.gifHeight,h=e.videoWidth,p=e.videoHeight,v=(+e.sampleInterval,+e.numWorkers,e.crop),b=+e.interval,w=s?0:1e3*b,y=e.progressCallback,C=e.savedRenderingContexts,S=e.saveRenderingContexts,k=[],x=C.length?C.length:e.numFrames,F=x,E=new g(e),W=e.text,O=e.fontWeight,A=n.getFontSize(e),U=e.fontFamily,R=e.fontColor,M=e.textAlign,I=e.textBaseline,T=e.textXCoordinate?e.textXCoordinate:"left"===M?1:"right"===M?m:m/2,V=e.textYCoordinate?e.textYCoordinate:"top"===I?1:"center"===I?f/2:f,j=O+" "+A+" "+U,H=v?Math.floor(v.scaledWidth/2):0,z=v?h-v.scaledWidth:0,L=v?Math.floor(v.scaledHeight/2):0,P=v?p-v.scaledHeight:0,B=function G(){function e(){try{z>h&&(z=h),P>p&&(P=p),0>H&&(H=0),0>L&&(L=0),i.drawImage(d,H,L,z,P,0,0,m,f),t()}catch(r){if("NS_ERROR_NOT_AVAILABLE"!==r.name)throw r;n.requestTimeout(e,100)}}function t(){F=o;var t,a,s,g,h=x-F;S&&k.push(i.getImageData(0,0,m,f)),W&&(i.font=j,i.fillStyle=R,i.textAlign=M,i.textBaseline=I,i.fillText(W,T,V)),t=i.getImageData(0,0,m,f),a=t.data,s=a[0]+a[1]+a[2]+a[3],g=0===s,g?1===h&&1===x&&e():E.addFrameImageData(t),y(h/x),o>0&&n.requestTimeout(G,w),F||E.getBase64GIF(function(e){r({error:!1,errorCode:"",errorMsg:"",image:e,cameraStream:u,videoElement:d,webcamVideoElement:l,savedRenderingContexts:k,keepCameraOn:c})})}var o=F-1;C.length?(i.putImageData(C[x-F],0,0),t()):e()};x=null!=x?x:10,b=null!=b?b:.1,o.width=m,o.height=f,i=o.getContext("2d"),function D(){return C.length||0!==d.currentTime?(B(),void 0):(n.requestTimeout(D,100),void 0)}()},getCropDimensions:function(e){var t=e.videoWidth,r=e.videoHeight,i=e.gifWidth,n=e.gifHeight,o={width:0,height:0,scaledWidth:0,scaledHeight:0};return t>r?(o.width=Math.round(t*(n/r))-i,o.scaledWidth=Math.round(o.width*(r/n))):(o.height=Math.round(r*(i/t))-n,o.scaledHeight=Math.round(o.height*(t/i))),o}},b={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function E(e){E.attempts=E.attempts||0;var t=this,r=e.videoElement,i=e.cameraStream,o=e.completedCallback;r&&(r.videoWidth>0&&r.videoHeight>0?(r.removeEventListener("loadeddata",t.findVideoSize),o({videoElement:r,cameraStream:i,videoWidth:r.videoWidth,videoHeight:r.videoHeight})):E.attempts<10?(E.attempts+=1,n.requestTimeout(function(){t.findVideoSize(e)},200)):o({videoElement:r,cameraStream:i,videoWidth:t.defaultVideoDimensions.width,videoHeight:t.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){n.isFunction(e)&&e({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - Timed out while trying to start streaming",image:null,cameraStream:{}})},stream:function(e){var t=this,r=n.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,i=e.videoElement,o=e.cameraStream,a=e.streamedCallback,s=e.completedCallback;n.isFunction(a)&&a(),r?n.isString(r)&&(i.src=r,i.innerHTML='<source src="'+r+'" type="video/'+n.getExtension(r)+'" />'):i.mozSrcObject?i.mozSrcObject=o:n.URL&&(i.src=n.URL.createObjectURL(o)),i.play(),n.requestTimeout(function d(){d.count=d.count||0,t.loadedData===!0?(t.findVideoSize({videoElement:i,cameraStream:o,completedCallback:s}),t.loadedData=!1):(d.count+=1,d.count>10?t.findVideoSize({videoElement:i,cameraStream:o,completedCallback:s}):d())},100)},startStreaming:function(e){var r=this,i=n.isFunction(e.error)?e.error:n.noop,o=n.isFunction(e.streamed)?e.streamed:n.noop,a=n.isFunction(e.completed)?e.completed:n.noop,s=e.existingVideo,d=e.webcamVideoElement,c=n.isElement(s)?s:d?d:t.createElement("video"),l=e.lastCameraStream,u=e.crossOrigin,m=e.options;u&&(c.crossOrigin=m.crossOrigin),c.autoplay=!0,c.loop=!0,c.muted=!0,c.addEventListener("loadeddata",function(){r.loadedData=!0}),s?r.stream({videoElement:c,existingVideo:s,completedCallback:a}):l?r.stream({videoElement:c,cameraStream:l,streamedCallback:o,completedCallback:a}):n.getUserMedia({video:!0},function(e){r.stream({videoElement:c,cameraStream:e,streamedCallback:o,completedCallback:a})},i)},startVideoStreaming:function(e,t){t=t||{};var r,o=this,a=t.timeout!==i?t.timeout:0,s=t.callback,d=t.webcamVideoElement;a>0&&(r=n.requestTimeout(function(){o.onStreamingTimeout(s)},1e4)),this.startStreaming({error:function(){s({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(r)},completed:function(t){var r=t.cameraStream,i=t.videoElement,n=t.videoWidth,o=t.videoHeight;e({cameraStream:r,videoElement:i,videoWidth:n,videoHeight:o})},lastCameraStream:t.lastCameraStream,webcamVideoElement:d,crossOrigin:t.crossOrigin,options:t})},stopVideoStreaming:function(e){e=n.isObject(e)?e:{};var t=e.cameraStream,r=e.videoElement,i=e.keepCameraOn,o=e.webcamVideoElement;!i&&t&&n.isFunction(t.stop)&&t.stop(),n.isElement(r)&&!o&&(r.pause(),n.isFunction(n.URL.revokeObjectURL)&&!n.webWorkerError&&r.src&&n.URL.revokeObjectURL(r.src),n.removeElement(r))}},w=function(e){e=n.isObject(e)?e:{};var t=(n.isObject(e.options)?e.options:{},e.cameraStream),r=e.videoElement,i=e.webcamVideoElement,o=e.keepCameraOn;b.stopVideoStreaming({cameraStream:t,videoElement:r,keepCameraOn:o,webcamVideoElement:i})},y=function(e,r){var i=e.options||{},o=i.images,a=i.video,s=(+i.numFrames,e.cameraStream),d=e.videoElement,c=e.videoWidth,l=e.videoHeight,u=+i.gifWidth,m=+i.gifHeight,f=v.getCropDimensions({videoWidth:c,videoHeight:l,gifHeight:m,gifWidth:u}),g=r;i.crop=f,i.videoElement=d,i.videoWidth=c,i.videoHeight=l,i.cameraStream=s,n.isElement(d)&&(d.width=u+f.width,d.height=m+f.height,i.webcamVideoElement||(n.setCSSAttr(d,{position:"fixed",opacity:"0"}),t.body.appendChild(d)),d.play(),v.getGIF(i,function(e){o&&o.length||a&&a.length||w(e),g(e)}))},C=function(e){var t,r,i=e.existingVideo,a=e.callback,s=e.options,d={getUserMedia:!0,"window.URL":!0},c=o.validate(d);if(c.error)return a(c);if(n.isElement(i)&&i.src){if(r=i.src,t=n.getExtension(r),!n.isSupported.videoCodecs[t])return a(o.messages.videoCodecs)}else n.isArray(i)&&n.each(i,function(e,r){return t=r.substr(r.lastIndexOf(".")+1,r.length),n.isSupported.videoCodecs[t]?(i=r,!1):void 0});b.startStreaming({completed:function(e){e.options=s||{},y(e,a)},existingVideo:i,crossOrigin:s.crossOrigin,options:s})},S=function(e){var t=e.lastCameraStream,r=e.callback,i=e.webcamVideoElement,n=e.options;return d()?n.savedRenderingContexts.length?(v.getWebcamGIF(n,function(e){r(e)}),void 0):(b.startVideoStreaming(function(e){e.options=n||{},y(e,r)},{lastCameraStream:t,callback:r,webcamVideoElement:i,crossOrigin:n.crossOrigin}),void 0):r(o.validate())},k=function(e,t){if(t=n.isFunction(e)?e:t,e=n.isObject(e)?e:{},n.isFunction(t)){var r=n.mergeOptions(a,e)||{},i=e.cameraStream,o=r.images,s=o?o.length:0,d=r.video,c=r.webcamVideoElement;r=n.mergeOptions(r,{gifWidth:Math.floor(r.gifWidth),gifHeight:Math.floor(r.gifHeight)}),s?p({images:o,imagesLength:s,callback:t,options:r}):d?C({existingVideo:d,callback:t,options:r}):S({lastCameraStream:i,callback:t,webcamVideoElement:c,options:r})}},x=function(e,t){if(t=n.isFunction(e)?e:t,e=n.isObject(e)?e:{},n.isFunction(t)){var r=n.mergeOptions(a,e),i=n.mergeOptions(r,{interval:.1,numFrames:1,gifWidth:Math.floor(r.gifWidth),gifHeight:Math.floor(r.gifHeight)});k(i,t)}},F=function(e,t,r,i,n,o,a,s,d,c){var l={utils:e,error:t,defaultOptions:r,createGIF:s,takeSnapShot:d,stopVideoStreaming:c,isSupported:i,isWebCamGIFSupported:n,isExistingVideoGIFSupported:a,isExistingImagesGIFSupported:o,VERSION:"0.3.2"};return l}(n,o,a,s,d,c,l,k,x,w),function(t){"function"==typeof define&&define.amd?define([],function(){return t}):"undefined"!=typeof exports?module.exports=t:e.gifshot=t}(F)}("undefined"!=typeof window?window:{},"undefined"!=typeof document?document:{createElement:function(){}},"undefined"!=typeof window?window.navigator:{});
\ No newline at end of file
diff --git a/web/index.html b/web/index.html
index c65a906ff..5415ce5a6 100644
--- a/web/index.html
+++ b/web/index.html
@@ -120,8 +120,8 @@
<!-- link.dev --> <script type="text/javascript" src="js/ol.wv/ol.wv.lookupimagetile.js"></script>
<!-- link.prod --> <!-- <script type="text/javascript" src="js/ol.js"></script> -->
- <!-- link.dev --> <script type="text/javascript" src="ext/anim/gifshot/gifshot.js"></script>
- <!-- link.prod --> <!-- <script type="text/javascript" src="ext/anim/gifshot/gifshot.min.js"></script> -->
+ <!-- link.dev --> <script type="text/javascript" src="ext/node_modules/gifshot/demo/gifshot.custom.js"></script>
+ <!-- link.prod --> <!-- <script type="text/javascript" src="ext/node_modules/gifshot/demo/gifshot.min.js"></script> -->
<!-- link.dev --> <script type="text/javascript" src="ext/main/jquery-2.1.4/jquery.js"></script>