@loaders.gl/video 3.4.14 → 3.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/gif-builder.js +62 -148
- package/dist/es5/gif-builder.js.map +1 -1
- package/dist/es5/index.js +2 -2
- package/dist/es5/lib/gifshot/gifshot-loader.js +13 -57
- package/dist/es5/lib/gifshot/gifshot-loader.js.map +1 -1
- package/dist/es5/lib/gifshot/gifshot.js +480 -482
- package/dist/es5/lib/gifshot/gifshot.js.map +1 -1
- package/dist/es5/lib/parsers/parse-video.js +5 -23
- package/dist/es5/lib/parsers/parse-video.js.map +1 -1
- package/dist/es5/video-loader.js +6 -6
- package/dist/es5/video-loader.js.map +1 -1
- package/dist/esm/video-loader.js +1 -1
- package/package.json +4 -4
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
|
-
var _readOnlyError2 = _interopRequireDefault(require("@babel/runtime/helpers/readOnlyError"));
|
|
9
7
|
var utils = {
|
|
10
8
|
URL: globalThis.URL || globalThis.webkitURL || globalThis.mozURL || globalThis.msURL,
|
|
11
9
|
getUserMedia: function () {
|
|
12
10
|
if (!globalThis.navigator) return globalThis.navigator;
|
|
13
|
-
|
|
11
|
+
const getUserMedia = globalThis.navigator.getUserMedia || globalThis.navigator.webkitGetUserMedia || globalThis.navigator.mozGetUserMedia || globalThis.navigator.msGetUserMedia;
|
|
14
12
|
return getUserMedia ? getUserMedia.bind(globalThis.navigator) : getUserMedia;
|
|
15
13
|
}(),
|
|
16
14
|
requestAnimFrame: globalThis.requestAnimationFrame || globalThis.webkitRequestAnimationFrame || globalThis.mozRequestAnimationFrame || globalThis.oRequestAnimationFrame || globalThis.msRequestAnimationFrame,
|
|
@@ -20,12 +18,12 @@ var utils = {
|
|
|
20
18
|
if (!utils.requestAnimFrame) {
|
|
21
19
|
return setTimeout(callback, delay);
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
const start = new Date().getTime();
|
|
22
|
+
const handle = new Object();
|
|
23
|
+
const requestAnimFrame = utils.requestAnimFrame;
|
|
24
|
+
const loop = function loop() {
|
|
25
|
+
const current = new Date().getTime();
|
|
26
|
+
const delta = current - start;
|
|
29
27
|
delta >= delay ? callback.call() : handle.value = requestAnimFrame(loop);
|
|
30
28
|
};
|
|
31
29
|
handle.value = requestAnimFrame(loop);
|
|
@@ -33,18 +31,18 @@ var utils = {
|
|
|
33
31
|
},
|
|
34
32
|
Blob: globalThis.Blob || globalThis.BlobBuilder || globalThis.WebKitBlobBuilder || globalThis.MozBlobBuilder || globalThis.MSBlobBuilder,
|
|
35
33
|
btoa: function () {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
const btoa = globalThis.btoa || function (input) {
|
|
35
|
+
let output = '';
|
|
36
|
+
let i = 0;
|
|
37
|
+
const l = input.length;
|
|
38
|
+
const key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
39
|
+
let chr1 = void 0;
|
|
40
|
+
let chr2 = void 0;
|
|
41
|
+
let chr3 = void 0;
|
|
42
|
+
let enc1 = void 0;
|
|
43
|
+
let enc2 = void 0;
|
|
44
|
+
let enc3 = void 0;
|
|
45
|
+
let enc4 = void 0;
|
|
48
46
|
while (i < l) {
|
|
49
47
|
chr1 = input.charCodeAt(i++);
|
|
50
48
|
chr2 = input.charCodeAt(i++);
|
|
@@ -84,7 +82,7 @@ var utils = {
|
|
|
84
82
|
},
|
|
85
83
|
isSupported: {
|
|
86
84
|
canvas: function canvas() {
|
|
87
|
-
|
|
85
|
+
const el = document.createElement('canvas');
|
|
88
86
|
return el && el.getContext && el.getContext('2d');
|
|
89
87
|
},
|
|
90
88
|
webworkers: function webworkers() {
|
|
@@ -100,8 +98,8 @@ var utils = {
|
|
|
100
98
|
return globalThis.Uint32Array;
|
|
101
99
|
},
|
|
102
100
|
videoCodecs: function () {
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
const testEl = document.createElement('video');
|
|
102
|
+
const supportObj = {
|
|
105
103
|
mp4: false,
|
|
106
104
|
h264: false,
|
|
107
105
|
ogv: false,
|
|
@@ -122,8 +120,8 @@ var utils = {
|
|
|
122
120
|
},
|
|
123
121
|
noop: function noop() {},
|
|
124
122
|
each: function each(collection, callback) {
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
let x = void 0;
|
|
124
|
+
let len = void 0;
|
|
127
125
|
if (utils.isArray(collection)) {
|
|
128
126
|
x = -1;
|
|
129
127
|
len = collection.length;
|
|
@@ -146,12 +144,12 @@ var utils = {
|
|
|
146
144
|
if (!utils.isObject(defaultOptions) || !utils.isObject(userOptions) || !Object.keys) {
|
|
147
145
|
return;
|
|
148
146
|
}
|
|
149
|
-
|
|
147
|
+
const newObj = {};
|
|
150
148
|
utils.each(defaultOptions, function (key, val) {
|
|
151
149
|
newObj[key] = defaultOptions[key];
|
|
152
150
|
});
|
|
153
151
|
utils.each(userOptions, function (key, val) {
|
|
154
|
-
|
|
152
|
+
const currentUserOption = userOptions[key];
|
|
155
153
|
if (!utils.isObject(currentUserOption)) {
|
|
156
154
|
newObj[key] = currentUserOption;
|
|
157
155
|
} else if (!defaultOptions[key]) {
|
|
@@ -187,14 +185,14 @@ var utils = {
|
|
|
187
185
|
return {};
|
|
188
186
|
}
|
|
189
187
|
try {
|
|
190
|
-
|
|
188
|
+
const blob = new utils.Blob([content], {
|
|
191
189
|
type: 'text/javascript'
|
|
192
190
|
});
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
const objectUrl = utils.URL.createObjectURL(blob);
|
|
192
|
+
const worker = new Worker(objectUrl);
|
|
195
193
|
return {
|
|
196
|
-
objectUrl
|
|
197
|
-
worker
|
|
194
|
+
objectUrl,
|
|
195
|
+
worker
|
|
198
196
|
};
|
|
199
197
|
} catch (e) {
|
|
200
198
|
return "".concat(e);
|
|
@@ -204,16 +202,16 @@ var utils = {
|
|
|
204
202
|
return src.substr(src.lastIndexOf('.') + 1, src.length);
|
|
205
203
|
},
|
|
206
204
|
getFontSize: function getFontSize() {
|
|
207
|
-
|
|
205
|
+
const options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
208
206
|
if (!document.body || options.resizeFont === false) {
|
|
209
207
|
return options.fontSize;
|
|
210
208
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
209
|
+
const text = options.text;
|
|
210
|
+
const containerWidth = options.gifWidth;
|
|
211
|
+
let fontSize = parseInt(options.fontSize, 10);
|
|
212
|
+
const minFontSize = parseInt(options.minFontSize, 10);
|
|
213
|
+
const div = document.createElement('div');
|
|
214
|
+
const span = document.createElement('span');
|
|
217
215
|
div.setAttribute('width', containerWidth);
|
|
218
216
|
div.appendChild(span);
|
|
219
217
|
span.innerHTML = text;
|
|
@@ -229,15 +227,15 @@ var utils = {
|
|
|
229
227
|
},
|
|
230
228
|
webWorkerError: false
|
|
231
229
|
};
|
|
232
|
-
|
|
230
|
+
const utils$2 = Object.freeze({
|
|
233
231
|
default: utils
|
|
234
232
|
});
|
|
235
233
|
var error = {
|
|
236
234
|
validate: function validate(skipObj) {
|
|
237
235
|
skipObj = utils.isObject(skipObj) ? skipObj : {};
|
|
238
|
-
|
|
236
|
+
let errorObj = {};
|
|
239
237
|
utils.each(error.validators, function (indece, currentValidator) {
|
|
240
|
-
|
|
238
|
+
const errorCode = currentValidator.errorCode;
|
|
241
239
|
if (!skipObj[errorCode] && !currentValidator.condition) {
|
|
242
240
|
errorObj = currentValidator;
|
|
243
241
|
errorObj.error = true;
|
|
@@ -248,8 +246,8 @@ var error = {
|
|
|
248
246
|
return errorObj;
|
|
249
247
|
},
|
|
250
248
|
isValid: function isValid(skipObj) {
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
const errorObj = error.validate(skipObj);
|
|
250
|
+
const isValid = errorObj.error !== true;
|
|
253
251
|
return isValid;
|
|
254
252
|
},
|
|
255
253
|
validators: [{
|
|
@@ -288,11 +286,11 @@ var error = {
|
|
|
288
286
|
}
|
|
289
287
|
}
|
|
290
288
|
};
|
|
291
|
-
|
|
289
|
+
const error$2 = Object.freeze({
|
|
292
290
|
default: error
|
|
293
291
|
});
|
|
294
|
-
|
|
295
|
-
|
|
292
|
+
const noop = function noop() {};
|
|
293
|
+
const defaultOptions = {
|
|
296
294
|
sampleInterval: 10,
|
|
297
295
|
numWorkers: 2,
|
|
298
296
|
filter: '',
|
|
@@ -323,7 +321,7 @@ var defaultOptions = {
|
|
|
323
321
|
savedRenderingContexts: [],
|
|
324
322
|
crossOrigin: 'Anonymous'
|
|
325
323
|
};
|
|
326
|
-
|
|
324
|
+
const defaultOptions$2 = Object.freeze({
|
|
327
325
|
default: defaultOptions
|
|
328
326
|
});
|
|
329
327
|
function isSupported() {
|
|
@@ -333,13 +331,13 @@ function isWebCamGIFSupported() {
|
|
|
333
331
|
return error.isValid();
|
|
334
332
|
}
|
|
335
333
|
function isSupported$1() {
|
|
336
|
-
|
|
334
|
+
const options = {
|
|
337
335
|
getUserMedia: true
|
|
338
336
|
};
|
|
339
337
|
return error.isValid(options);
|
|
340
338
|
}
|
|
341
339
|
function isExistingVideoGIFSupported(codecs) {
|
|
342
|
-
|
|
340
|
+
let hasValidCodec = false;
|
|
343
341
|
if (utils.isArray(codecs) && codecs.length) {
|
|
344
342
|
utils.each(codecs, function (indece, currentCodec) {
|
|
345
343
|
if (utils.isSupported.videoCodecs[currentCodec]) {
|
|
@@ -359,45 +357,45 @@ function isExistingVideoGIFSupported(codecs) {
|
|
|
359
357
|
});
|
|
360
358
|
}
|
|
361
359
|
function NeuQuant() {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
360
|
+
const netsize = 256;
|
|
361
|
+
const prime1 = 499;
|
|
362
|
+
const prime2 = 491;
|
|
363
|
+
const prime3 = 487;
|
|
364
|
+
const prime4 = 503;
|
|
365
|
+
const minpicturebytes = 3 * prime4;
|
|
366
|
+
const maxnetpos = netsize - 1;
|
|
367
|
+
const netbiasshift = 4;
|
|
368
|
+
const ncycles = 100;
|
|
369
|
+
const intbiasshift = 16;
|
|
370
|
+
const intbias = 1 << intbiasshift;
|
|
371
|
+
const gammashift = 10;
|
|
372
|
+
const gamma = 1 << gammashift;
|
|
373
|
+
const betashift = 10;
|
|
374
|
+
const beta = intbias >> betashift;
|
|
375
|
+
const betagamma = intbias << gammashift - betashift;
|
|
376
|
+
const initrad = netsize >> 3;
|
|
377
|
+
const radiusbiasshift = 6;
|
|
378
|
+
const radiusbias = 1 << radiusbiasshift;
|
|
379
|
+
const initradius = initrad * radiusbias;
|
|
380
|
+
const radiusdec = 30;
|
|
381
|
+
const alphabiasshift = 10;
|
|
382
|
+
const initalpha = 1 << alphabiasshift;
|
|
383
|
+
let alphadec;
|
|
384
|
+
const radbiasshift = 8;
|
|
385
|
+
const radbias = 1 << radbiasshift;
|
|
386
|
+
const alpharadbshift = alphabiasshift + radbiasshift;
|
|
387
|
+
const alpharadbias = 1 << alpharadbshift;
|
|
388
|
+
let thepicture;
|
|
389
|
+
let lengthcount;
|
|
390
|
+
let samplefac;
|
|
391
|
+
let network;
|
|
392
|
+
const netindex = [];
|
|
393
|
+
const bias = [];
|
|
394
|
+
const freq = [];
|
|
395
|
+
const radpower = [];
|
|
398
396
|
function NeuQuantConstructor(thepic, len, sample) {
|
|
399
|
-
|
|
400
|
-
|
|
397
|
+
let i;
|
|
398
|
+
let p;
|
|
401
399
|
thepicture = thepic;
|
|
402
400
|
lengthcount = len;
|
|
403
401
|
samplefac = sample;
|
|
@@ -411,14 +409,14 @@ function NeuQuant() {
|
|
|
411
409
|
}
|
|
412
410
|
}
|
|
413
411
|
function colorMap() {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
for (
|
|
412
|
+
const map = [];
|
|
413
|
+
const index = new Array(netsize);
|
|
414
|
+
for (let i = 0; i < netsize; i++) {
|
|
417
415
|
index[network[i][3]] = i;
|
|
418
416
|
}
|
|
419
|
-
|
|
420
|
-
for (
|
|
421
|
-
|
|
417
|
+
let k = 0;
|
|
418
|
+
for (let l = 0; l < netsize; l++) {
|
|
419
|
+
const j = index[l];
|
|
422
420
|
map[k++] = network[j][0];
|
|
423
421
|
map[k++] = network[j][1];
|
|
424
422
|
map[k++] = network[j][2];
|
|
@@ -426,14 +424,14 @@ function NeuQuant() {
|
|
|
426
424
|
return map;
|
|
427
425
|
}
|
|
428
426
|
function inxbuild() {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
427
|
+
let i;
|
|
428
|
+
let j;
|
|
429
|
+
let smallpos;
|
|
430
|
+
let smallval;
|
|
431
|
+
let p;
|
|
432
|
+
let q;
|
|
433
|
+
let previouscol;
|
|
434
|
+
let startpos;
|
|
437
435
|
previouscol = 0;
|
|
438
436
|
startpos = 0;
|
|
439
437
|
for (i = 0; i < netsize; i++) {
|
|
@@ -477,20 +475,20 @@ function NeuQuant() {
|
|
|
477
475
|
}
|
|
478
476
|
}
|
|
479
477
|
function learn() {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
478
|
+
let i;
|
|
479
|
+
let j;
|
|
480
|
+
let b;
|
|
481
|
+
let g;
|
|
482
|
+
let r;
|
|
483
|
+
let radius;
|
|
484
|
+
let rad;
|
|
485
|
+
let alpha;
|
|
486
|
+
let step;
|
|
487
|
+
let delta;
|
|
488
|
+
let samplepixels;
|
|
489
|
+
let p;
|
|
490
|
+
let pix;
|
|
491
|
+
let lim;
|
|
494
492
|
if (lengthcount < minpicturebytes) {
|
|
495
493
|
samplefac = 1;
|
|
496
494
|
}
|
|
@@ -552,13 +550,13 @@ function NeuQuant() {
|
|
|
552
550
|
}
|
|
553
551
|
}
|
|
554
552
|
function map(b, g, r) {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
553
|
+
let i;
|
|
554
|
+
let j;
|
|
555
|
+
let dist;
|
|
556
|
+
let a;
|
|
557
|
+
let bestd;
|
|
558
|
+
let p;
|
|
559
|
+
let best;
|
|
562
560
|
bestd = 1000;
|
|
563
561
|
best = -1;
|
|
564
562
|
i = netindex[g];
|
|
@@ -630,8 +628,8 @@ function NeuQuant() {
|
|
|
630
628
|
return colorMap();
|
|
631
629
|
}
|
|
632
630
|
function unbiasnet() {
|
|
633
|
-
|
|
634
|
-
|
|
631
|
+
let i;
|
|
632
|
+
let j;
|
|
635
633
|
for (i = 0; i < netsize; i++) {
|
|
636
634
|
network[i][0] >>= netbiasshift;
|
|
637
635
|
network[i][1] >>= netbiasshift;
|
|
@@ -640,13 +638,13 @@ function NeuQuant() {
|
|
|
640
638
|
}
|
|
641
639
|
}
|
|
642
640
|
function alterneigh(rad, i, b, g, r) {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
641
|
+
let j;
|
|
642
|
+
let k;
|
|
643
|
+
let lo;
|
|
644
|
+
let hi;
|
|
645
|
+
let a;
|
|
646
|
+
let m;
|
|
647
|
+
let p;
|
|
650
648
|
lo = i - rad;
|
|
651
649
|
if (lo < -1) {
|
|
652
650
|
lo = -1;
|
|
@@ -679,23 +677,23 @@ function NeuQuant() {
|
|
|
679
677
|
}
|
|
680
678
|
}
|
|
681
679
|
function altersingle(alpha, i, b, g, r) {
|
|
682
|
-
|
|
683
|
-
|
|
680
|
+
const n = network[i];
|
|
681
|
+
const alphaMult = alpha / initalpha;
|
|
684
682
|
n[0] -= alphaMult * (n[0] - b) | 0;
|
|
685
683
|
n[1] -= alphaMult * (n[1] - g) | 0;
|
|
686
684
|
n[2] -= alphaMult * (n[2] - r) | 0;
|
|
687
685
|
}
|
|
688
686
|
function contest(b, g, r) {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
687
|
+
let i;
|
|
688
|
+
let dist;
|
|
689
|
+
let a;
|
|
690
|
+
let biasdist;
|
|
691
|
+
let betafreq;
|
|
692
|
+
let bestpos;
|
|
693
|
+
let bestbiaspos;
|
|
694
|
+
let bestd;
|
|
695
|
+
let bestbiasd;
|
|
696
|
+
let n;
|
|
699
697
|
bestd = ~(1 << 31);
|
|
700
698
|
bestbiasd = bestd;
|
|
701
699
|
bestpos = -1;
|
|
@@ -734,17 +732,17 @@ function NeuQuant() {
|
|
|
734
732
|
return bestbiaspos;
|
|
735
733
|
}
|
|
736
734
|
NeuQuantConstructor.apply(this, arguments);
|
|
737
|
-
|
|
735
|
+
const exports = {};
|
|
738
736
|
exports.map = map;
|
|
739
737
|
exports.process = process;
|
|
740
738
|
return exports;
|
|
741
739
|
}
|
|
742
740
|
function workerCode() {
|
|
743
|
-
|
|
741
|
+
const self = this;
|
|
744
742
|
try {
|
|
745
743
|
globalThis.onmessage = function (ev) {
|
|
746
|
-
|
|
747
|
-
|
|
744
|
+
const data = ev.data || {};
|
|
745
|
+
let response;
|
|
748
746
|
if (data.gifshot) {
|
|
749
747
|
response = workerMethods.run(data);
|
|
750
748
|
postMessage(response);
|
|
@@ -753,9 +751,9 @@ function workerCode() {
|
|
|
753
751
|
} catch (e) {}
|
|
754
752
|
var workerMethods = {
|
|
755
753
|
dataToRGB: function dataToRGB(data, width, height) {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
754
|
+
const length = width * height * 4;
|
|
755
|
+
let i = 0;
|
|
756
|
+
const rgb = [];
|
|
759
757
|
while (i < length) {
|
|
760
758
|
rgb.push(data[i++]);
|
|
761
759
|
rgb.push(data[i++]);
|
|
@@ -766,27 +764,27 @@ function workerCode() {
|
|
|
766
764
|
},
|
|
767
765
|
componentizedPaletteToArray: function componentizedPaletteToArray(paletteRGB) {
|
|
768
766
|
paletteRGB = paletteRGB || [];
|
|
769
|
-
|
|
770
|
-
for (
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
767
|
+
const paletteArray = [];
|
|
768
|
+
for (let i = 0; i < paletteRGB.length; i += 3) {
|
|
769
|
+
const r = paletteRGB[i];
|
|
770
|
+
const g = paletteRGB[i + 1];
|
|
771
|
+
const b = paletteRGB[i + 2];
|
|
774
772
|
paletteArray.push(r << 16 | g << 8 | b);
|
|
775
773
|
}
|
|
776
774
|
return paletteArray;
|
|
777
775
|
},
|
|
778
776
|
processFrameWithQuantizer: function processFrameWithQuantizer(imageData, width, height, sampleInterval) {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
for (
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
777
|
+
const rgbComponents = this.dataToRGB(imageData, width, height);
|
|
778
|
+
const nq = new NeuQuant(rgbComponents, rgbComponents.length, sampleInterval);
|
|
779
|
+
const paletteRGB = nq.process();
|
|
780
|
+
const paletteArray = new Uint32Array(this.componentizedPaletteToArray(paletteRGB));
|
|
781
|
+
const numberPixels = width * height;
|
|
782
|
+
const indexedPixels = new Uint8Array(numberPixels);
|
|
783
|
+
let k = 0;
|
|
784
|
+
for (let i = 0; i < numberPixels; i++) {
|
|
785
|
+
const r = rgbComponents[k++];
|
|
786
|
+
const g = rgbComponents[k++];
|
|
787
|
+
const b = rgbComponents[k++];
|
|
790
788
|
indexedPixels[i] = nq.map(r, g, b);
|
|
791
789
|
}
|
|
792
790
|
return {
|
|
@@ -796,25 +794,25 @@ function workerCode() {
|
|
|
796
794
|
},
|
|
797
795
|
run: function run(frame) {
|
|
798
796
|
frame = frame || {};
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
797
|
+
const _frame = frame;
|
|
798
|
+
const height = _frame.height;
|
|
799
|
+
const palette = _frame.palette;
|
|
800
|
+
const sampleInterval = _frame.sampleInterval;
|
|
801
|
+
const width = _frame.width;
|
|
802
|
+
const imageData = frame.data;
|
|
805
803
|
return this.processFrameWithQuantizer(imageData, width, height, sampleInterval);
|
|
806
804
|
}
|
|
807
805
|
};
|
|
808
806
|
return workerMethods;
|
|
809
807
|
}
|
|
810
808
|
function gifWriter(buf, width, height, gopts) {
|
|
811
|
-
|
|
809
|
+
let p = 0;
|
|
812
810
|
gopts = gopts === undefined ? {} : gopts;
|
|
813
|
-
|
|
814
|
-
|
|
811
|
+
const loop_count = gopts.loop === undefined ? null : gopts.loop;
|
|
812
|
+
const global_palette = gopts.palette === undefined ? null : gopts.palette;
|
|
815
813
|
if (width <= 0 || height <= 0 || width > 65535 || height > 65535) throw 'Width/Height invalid.';
|
|
816
814
|
function check_palette_and_num_colors(palette) {
|
|
817
|
-
|
|
815
|
+
const num_colors = palette.length;
|
|
818
816
|
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.';
|
|
819
817
|
return num_colors;
|
|
820
818
|
}
|
|
@@ -824,8 +822,8 @@ function gifWriter(buf, width, height, gopts) {
|
|
|
824
822
|
buf[p++] = 0x38;
|
|
825
823
|
buf[p++] = 0x39;
|
|
826
824
|
buf[p++] = 0x61;
|
|
827
|
-
|
|
828
|
-
|
|
825
|
+
const gp_num_colors_pow2 = 0;
|
|
826
|
+
const background = 0;
|
|
829
827
|
buf[p++] = width & 0xff;
|
|
830
828
|
buf[p++] = width >> 8 & 0xff;
|
|
831
829
|
buf[p++] = height & 0xff;
|
|
@@ -855,7 +853,7 @@ function gifWriter(buf, width, height, gopts) {
|
|
|
855
853
|
buf[p++] = loop_count >> 8 & 0xff;
|
|
856
854
|
buf[p++] = 0x00;
|
|
857
855
|
}
|
|
858
|
-
|
|
856
|
+
let ended = false;
|
|
859
857
|
this.addFrame = function (x, y, w, h, indexed_pixels, opts) {
|
|
860
858
|
if (ended === true) {
|
|
861
859
|
--p;
|
|
@@ -865,24 +863,24 @@ function gifWriter(buf, width, height, gopts) {
|
|
|
865
863
|
if (x < 0 || y < 0 || x > 65535 || y > 65535) throw 'x/y invalid.';
|
|
866
864
|
if (w <= 0 || h <= 0 || w > 65535 || h > 65535) throw 'Width/Height invalid.';
|
|
867
865
|
if (indexed_pixels.length < w * h) throw 'Not enough pixels for the frame size.';
|
|
868
|
-
|
|
869
|
-
|
|
866
|
+
let using_local_palette = true;
|
|
867
|
+
let palette = opts.palette;
|
|
870
868
|
if (palette === undefined || palette === null) {
|
|
871
869
|
using_local_palette = false;
|
|
872
870
|
palette = global_palette;
|
|
873
871
|
}
|
|
874
872
|
if (palette === undefined || palette === null) throw 'Must supply either a local or global palette.';
|
|
875
|
-
|
|
876
|
-
|
|
873
|
+
let num_colors = check_palette_and_num_colors(palette);
|
|
874
|
+
let min_code_size = 0;
|
|
877
875
|
while (num_colors >>= 1) {
|
|
878
876
|
++min_code_size;
|
|
879
877
|
}
|
|
880
878
|
num_colors = 1 << min_code_size;
|
|
881
|
-
|
|
882
|
-
|
|
879
|
+
const delay = opts.delay === undefined ? 0 : opts.delay;
|
|
880
|
+
const disposal = opts.disposal === undefined ? 0 : opts.disposal;
|
|
883
881
|
if (disposal < 0 || disposal > 3) throw 'Disposal out of range.';
|
|
884
|
-
|
|
885
|
-
|
|
882
|
+
let use_transparency = false;
|
|
883
|
+
let transparent_index = 0;
|
|
886
884
|
if (opts.transparent !== undefined && opts.transparent !== null) {
|
|
887
885
|
use_transparency = true;
|
|
888
886
|
transparent_index = opts.transparent;
|
|
@@ -909,8 +907,8 @@ function gifWriter(buf, width, height, gopts) {
|
|
|
909
907
|
buf[p++] = h >> 8 & 0xff;
|
|
910
908
|
buf[p++] = using_local_palette === true ? 0x80 | min_code_size - 1 : 0;
|
|
911
909
|
if (using_local_palette === true) {
|
|
912
|
-
for (
|
|
913
|
-
|
|
910
|
+
for (let i = 0, il = palette.length; i < il; ++i) {
|
|
911
|
+
const rgb = palette[i];
|
|
914
912
|
buf[p++] = rgb >> 16 & 0xff;
|
|
915
913
|
buf[p++] = rgb >> 8 & 0xff;
|
|
916
914
|
buf[p++] = rgb & 0xff;
|
|
@@ -927,14 +925,14 @@ function gifWriter(buf, width, height, gopts) {
|
|
|
927
925
|
};
|
|
928
926
|
function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) {
|
|
929
927
|
buf[p++] = min_code_size;
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
928
|
+
let cur_subblock = p++;
|
|
929
|
+
const clear_code = 1 << min_code_size;
|
|
930
|
+
const code_mask = clear_code - 1;
|
|
931
|
+
const eoi_code = clear_code + 1;
|
|
932
|
+
let next_code = eoi_code + 1;
|
|
933
|
+
let cur_code_size = min_code_size + 1;
|
|
934
|
+
let cur_shift = 0;
|
|
935
|
+
let cur = 0;
|
|
938
936
|
function emit_bytes_to_buffer(bit_block_size) {
|
|
939
937
|
while (cur_shift >= bit_block_size) {
|
|
940
938
|
buf[p++] = cur & 0xff;
|
|
@@ -951,13 +949,13 @@ function gifWriter(buf, width, height, gopts) {
|
|
|
951
949
|
cur_shift += cur_code_size;
|
|
952
950
|
emit_bytes_to_buffer(8);
|
|
953
951
|
}
|
|
954
|
-
|
|
955
|
-
|
|
952
|
+
let ib_code = index_stream[0] & code_mask;
|
|
953
|
+
let code_table = {};
|
|
956
954
|
emit_code(clear_code);
|
|
957
|
-
for (
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
955
|
+
for (let i = 1, il = index_stream.length; i < il; ++i) {
|
|
956
|
+
const k = index_stream[i] & code_mask;
|
|
957
|
+
const cur_key = ib_code << 8 | k;
|
|
958
|
+
const cur_code = code_table[cur_key];
|
|
961
959
|
if (cur_code === undefined) {
|
|
962
960
|
cur |= ib_code << cur_shift;
|
|
963
961
|
cur_shift += cur_code_size;
|
|
@@ -996,8 +994,8 @@ function gifWriter(buf, width, height, gopts) {
|
|
|
996
994
|
return p;
|
|
997
995
|
}
|
|
998
996
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
997
|
+
const noop$2 = function noop() {};
|
|
998
|
+
const AnimatedGIF = function AnimatedGIF(options) {
|
|
1001
999
|
this.canvas = null;
|
|
1002
1000
|
this.ctx = null;
|
|
1003
1001
|
this.repeat = 0;
|
|
@@ -1014,14 +1012,14 @@ var AnimatedGIF = function AnimatedGIF(options) {
|
|
|
1014
1012
|
AnimatedGIF.prototype = {
|
|
1015
1013
|
workerMethods: workerCode(),
|
|
1016
1014
|
initializeWebWorkers: function initializeWebWorkers(options) {
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1015
|
+
const self = this;
|
|
1016
|
+
const processFrameWorkerCode = "".concat(NeuQuant.toString(), "(").concat(workerCode.toString(), "());");
|
|
1017
|
+
let webWorkerObj = void 0;
|
|
1018
|
+
let objectUrl = void 0;
|
|
1019
|
+
let webWorker = void 0;
|
|
1020
|
+
let numWorkers = void 0;
|
|
1021
|
+
let x = -1;
|
|
1022
|
+
let workerError = '';
|
|
1025
1023
|
numWorkers = options.numWorkers;
|
|
1026
1024
|
while (++x < numWorkers) {
|
|
1027
1025
|
webWorkerObj = utils.createWebWorker(processFrameWorkerCode);
|
|
@@ -1030,7 +1028,7 @@ AnimatedGIF.prototype = {
|
|
|
1030
1028
|
webWorker = webWorkerObj.worker;
|
|
1031
1029
|
self.workers.push({
|
|
1032
1030
|
worker: webWorker,
|
|
1033
|
-
objectUrl
|
|
1031
|
+
objectUrl
|
|
1034
1032
|
});
|
|
1035
1033
|
self.availableWorkers.push(webWorker);
|
|
1036
1034
|
} else {
|
|
@@ -1052,27 +1050,27 @@ AnimatedGIF.prototype = {
|
|
|
1052
1050
|
this.availableWorkers.push(worker);
|
|
1053
1051
|
},
|
|
1054
1052
|
byteMap: function () {
|
|
1055
|
-
|
|
1056
|
-
for (
|
|
1053
|
+
const byteMap = [];
|
|
1054
|
+
for (let i = 0; i < 256; i++) {
|
|
1057
1055
|
byteMap[i] = String.fromCharCode(i);
|
|
1058
1056
|
}
|
|
1059
1057
|
return byteMap;
|
|
1060
1058
|
}(),
|
|
1061
1059
|
bufferToString: function bufferToString(buffer) {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1060
|
+
const numberValues = buffer.length;
|
|
1061
|
+
let str = '';
|
|
1062
|
+
let x = -1;
|
|
1065
1063
|
while (++x < numberValues) {
|
|
1066
1064
|
str += this.byteMap[buffer[x]];
|
|
1067
1065
|
}
|
|
1068
1066
|
return str;
|
|
1069
1067
|
},
|
|
1070
1068
|
onFrameFinished: function onFrameFinished(progressCallback) {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1069
|
+
const self = this;
|
|
1070
|
+
const frames = self.frames;
|
|
1071
|
+
const options = self.options;
|
|
1072
|
+
const hasExistingImages = Boolean((options.images || []).length);
|
|
1073
|
+
const allDone = frames.every(function (frame) {
|
|
1076
1074
|
return !frame.beingProcessed && frame.done;
|
|
1077
1075
|
});
|
|
1078
1076
|
self.numRenderedFrames++;
|
|
@@ -1091,17 +1089,17 @@ AnimatedGIF.prototype = {
|
|
|
1091
1089
|
}
|
|
1092
1090
|
},
|
|
1093
1091
|
processFrame: function processFrame(position) {
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1092
|
+
const AnimatedGifContext = this;
|
|
1093
|
+
const options = this.options;
|
|
1094
|
+
const _options = this.options;
|
|
1095
|
+
const progressCallback = _options.progressCallback;
|
|
1096
|
+
const sampleInterval = _options.sampleInterval;
|
|
1097
|
+
const frames = this.frames;
|
|
1098
|
+
let frame = void 0;
|
|
1099
|
+
let worker = void 0;
|
|
1100
|
+
const done = function done() {
|
|
1101
|
+
const ev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1102
|
+
const data = ev.data;
|
|
1105
1103
|
delete frame.data;
|
|
1106
1104
|
frame.pixels = Array.prototype.slice.call(data.pixels);
|
|
1107
1105
|
frame.palette = Array.prototype.slice.call(data.palette);
|
|
@@ -1130,14 +1128,14 @@ AnimatedGIF.prototype = {
|
|
|
1130
1128
|
},
|
|
1131
1129
|
startRendering: function startRendering(completeCallback) {
|
|
1132
1130
|
this.onRenderCompleteCallback = completeCallback;
|
|
1133
|
-
for (
|
|
1131
|
+
for (let i = 0; i < this.options.numWorkers && i < this.frames.length; i++) {
|
|
1134
1132
|
this.processFrame(i);
|
|
1135
1133
|
}
|
|
1136
1134
|
},
|
|
1137
1135
|
processNextFrame: function processNextFrame() {
|
|
1138
|
-
|
|
1139
|
-
for (
|
|
1140
|
-
|
|
1136
|
+
let position = -1;
|
|
1137
|
+
for (let i = 0; i < this.frames.length; i++) {
|
|
1138
|
+
const frame = this.frames[i];
|
|
1141
1139
|
if (!frame.done && !frame.beingProcessed) {
|
|
1142
1140
|
position = i;
|
|
1143
1141
|
break;
|
|
@@ -1148,30 +1146,30 @@ AnimatedGIF.prototype = {
|
|
|
1148
1146
|
}
|
|
1149
1147
|
},
|
|
1150
1148
|
generateGIF: function generateGIF(frames, callback) {
|
|
1151
|
-
|
|
1152
|
-
|
|
1149
|
+
const buffer = [];
|
|
1150
|
+
const gifOptions = {
|
|
1153
1151
|
loop: this.repeat
|
|
1154
1152
|
};
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1153
|
+
const options = this.options;
|
|
1154
|
+
const interval = options.interval;
|
|
1155
|
+
const frameDuration = options.frameDuration;
|
|
1156
|
+
const existingImages = options.images;
|
|
1157
|
+
const hasExistingImages = Boolean(existingImages.length);
|
|
1158
|
+
const height = options.gifHeight;
|
|
1159
|
+
const width = options.gifWidth;
|
|
1160
|
+
const gifWriter$$1 = new gifWriter(buffer, width, height, gifOptions);
|
|
1161
|
+
const onRenderProgressCallback = this.onRenderProgressCallback;
|
|
1162
|
+
const delay = hasExistingImages ? interval * 100 : 0;
|
|
1163
|
+
let bufferToString = void 0;
|
|
1164
|
+
let gif = void 0;
|
|
1167
1165
|
this.generatingGIF = true;
|
|
1168
1166
|
utils.each(frames, function (iterator, frame) {
|
|
1169
|
-
|
|
1167
|
+
const framePalette = frame.palette;
|
|
1170
1168
|
onRenderProgressCallback(0.75 + 0.25 * frame.position * 1.0 / frames.length);
|
|
1171
|
-
for (
|
|
1169
|
+
for (let i = 0; i < frameDuration; i++) {
|
|
1172
1170
|
gifWriter$$1.addFrame(0, 0, width, height, frame.pixels, {
|
|
1173
1171
|
palette: framePalette,
|
|
1174
|
-
delay
|
|
1172
|
+
delay
|
|
1175
1173
|
});
|
|
1176
1174
|
}
|
|
1177
1175
|
});
|
|
@@ -1190,26 +1188,26 @@ AnimatedGIF.prototype = {
|
|
|
1190
1188
|
},
|
|
1191
1189
|
addFrame: function addFrame(element, gifshotOptions) {
|
|
1192
1190
|
gifshotOptions = utils.isObject(gifshotOptions) ? gifshotOptions : {};
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1191
|
+
const self = this;
|
|
1192
|
+
const ctx = self.ctx;
|
|
1193
|
+
const options = self.options;
|
|
1194
|
+
const width = options.gifWidth;
|
|
1195
|
+
const height = options.gifHeight;
|
|
1196
|
+
const fontSize = utils.getFontSize(gifshotOptions);
|
|
1197
|
+
const _gifshotOptions = gifshotOptions;
|
|
1198
|
+
const filter = _gifshotOptions.filter;
|
|
1199
|
+
const fontColor = _gifshotOptions.fontColor;
|
|
1200
|
+
const fontFamily = _gifshotOptions.fontFamily;
|
|
1201
|
+
const fontWeight = _gifshotOptions.fontWeight;
|
|
1202
|
+
const gifHeight = _gifshotOptions.gifHeight;
|
|
1203
|
+
const gifWidth = _gifshotOptions.gifWidth;
|
|
1204
|
+
const text = _gifshotOptions.text;
|
|
1205
|
+
const textAlign = _gifshotOptions.textAlign;
|
|
1206
|
+
const textBaseline = _gifshotOptions.textBaseline;
|
|
1207
|
+
const textXCoordinate = gifshotOptions.textXCoordinate ? gifshotOptions.textXCoordinate : textAlign === 'left' ? 1 : textAlign === 'right' ? width : width / 2;
|
|
1208
|
+
const textYCoordinate = gifshotOptions.textYCoordinate ? gifshotOptions.textYCoordinate : textBaseline === 'top' ? 1 : textBaseline === 'center' ? height / 2 : height;
|
|
1209
|
+
const font = "".concat(fontWeight, " ").concat(fontSize, " ").concat(fontFamily);
|
|
1210
|
+
let imageData = void 0;
|
|
1213
1211
|
try {
|
|
1214
1212
|
ctx.filter = filter;
|
|
1215
1213
|
ctx.drawImage(element, 0, 0, width, height);
|
|
@@ -1227,9 +1225,9 @@ AnimatedGIF.prototype = {
|
|
|
1227
1225
|
}
|
|
1228
1226
|
},
|
|
1229
1227
|
addFrameImageData: function addFrameImageData() {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1228
|
+
const imageData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1229
|
+
const frames = this.frames;
|
|
1230
|
+
const imageDataArray = imageData.data;
|
|
1233
1231
|
this.frames.push({
|
|
1234
1232
|
data: imageDataArray,
|
|
1235
1233
|
width: imageData.width,
|
|
@@ -1248,8 +1246,8 @@ AnimatedGIF.prototype = {
|
|
|
1248
1246
|
return this.generatingGIF;
|
|
1249
1247
|
},
|
|
1250
1248
|
getBase64GIF: function getBase64GIF(completeCallback) {
|
|
1251
|
-
|
|
1252
|
-
|
|
1249
|
+
const self = this;
|
|
1250
|
+
const onRenderComplete = function onRenderComplete(gif) {
|
|
1253
1251
|
self.destroyWorkers();
|
|
1254
1252
|
utils.requestTimeout(function () {
|
|
1255
1253
|
completeCallback(gif);
|
|
@@ -1261,10 +1259,10 @@ AnimatedGIF.prototype = {
|
|
|
1261
1259
|
if (this.workerError) {
|
|
1262
1260
|
return;
|
|
1263
1261
|
}
|
|
1264
|
-
|
|
1262
|
+
const workers = this.workers;
|
|
1265
1263
|
utils.each(workers, function (iterator, workerObj) {
|
|
1266
|
-
|
|
1267
|
-
|
|
1264
|
+
const worker = workerObj.worker;
|
|
1265
|
+
const objectUrl = workerObj.objectUrl;
|
|
1268
1266
|
worker.terminate();
|
|
1269
1267
|
utils.URL.revokeObjectURL(objectUrl);
|
|
1270
1268
|
});
|
|
@@ -1276,32 +1274,32 @@ function getBase64GIF(animatedGifInstance, callback) {
|
|
|
1276
1274
|
error: false,
|
|
1277
1275
|
errorCode: '',
|
|
1278
1276
|
errorMsg: '',
|
|
1279
|
-
image
|
|
1277
|
+
image
|
|
1280
1278
|
});
|
|
1281
1279
|
});
|
|
1282
1280
|
}
|
|
1283
1281
|
function existingImages() {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1282
|
+
const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1283
|
+
const self = this;
|
|
1284
|
+
const callback = obj.callback;
|
|
1285
|
+
const images = obj.images;
|
|
1286
|
+
const options = obj.options;
|
|
1287
|
+
let imagesLength = obj.imagesLength;
|
|
1288
|
+
const skipObj = {
|
|
1291
1289
|
getUserMedia: true,
|
|
1292
1290
|
'globalThis.URL': true
|
|
1293
1291
|
};
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1292
|
+
const errorObj = error.validate(skipObj);
|
|
1293
|
+
const loadedImages = [];
|
|
1294
|
+
let loadedImagesLength = 0;
|
|
1295
|
+
let tempImage = void 0;
|
|
1296
|
+
let ag = void 0;
|
|
1299
1297
|
if (errorObj.error) {
|
|
1300
1298
|
return callback(errorObj);
|
|
1301
1299
|
}
|
|
1302
1300
|
ag = new AnimatedGIF(options);
|
|
1303
1301
|
utils.each(images, function (index, image) {
|
|
1304
|
-
|
|
1302
|
+
const currentImage = image;
|
|
1305
1303
|
if (utils.isElement(currentImage)) {
|
|
1306
1304
|
if (options.crossOrigin) {
|
|
1307
1305
|
currentImage.crossOrigin = options.crossOrigin;
|
|
@@ -1321,7 +1319,7 @@ function existingImages() {
|
|
|
1321
1319
|
tempImage.text = image.text;
|
|
1322
1320
|
}
|
|
1323
1321
|
tempImage.onerror = function (e) {
|
|
1324
|
-
|
|
1322
|
+
let obj = void 0;
|
|
1325
1323
|
--imagesLength;
|
|
1326
1324
|
if (imagesLength === 0) {
|
|
1327
1325
|
obj = {};
|
|
@@ -1366,53 +1364,53 @@ function existingImages() {
|
|
|
1366
1364
|
getBase64GIF(ag, callback);
|
|
1367
1365
|
}
|
|
1368
1366
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1367
|
+
const noop$3 = function noop() {};
|
|
1368
|
+
const screenShot = {
|
|
1371
1369
|
getGIF: function getGIF() {
|
|
1372
|
-
|
|
1373
|
-
|
|
1370
|
+
const options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1371
|
+
let callback = arguments[1];
|
|
1374
1372
|
callback = utils.isFunction(callback) ? callback : noop$3;
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1373
|
+
const canvas = document.createElement('canvas');
|
|
1374
|
+
let context = void 0;
|
|
1375
|
+
const existingImages = options.images;
|
|
1376
|
+
const hasExistingImages = Boolean(existingImages.length);
|
|
1377
|
+
const cameraStream = options.cameraStream;
|
|
1378
|
+
const crop = options.crop;
|
|
1379
|
+
const filter = options.filter;
|
|
1380
|
+
const fontColor = options.fontColor;
|
|
1381
|
+
const fontFamily = options.fontFamily;
|
|
1382
|
+
const fontWeight = options.fontWeight;
|
|
1383
|
+
const keepCameraOn = options.keepCameraOn;
|
|
1384
|
+
const numWorkers = options.numWorkers;
|
|
1385
|
+
const progressCallback = options.progressCallback;
|
|
1386
|
+
const saveRenderingContexts = options.saveRenderingContexts;
|
|
1387
|
+
const savedRenderingContexts = options.savedRenderingContexts;
|
|
1388
|
+
const text = options.text;
|
|
1389
|
+
const textAlign = options.textAlign;
|
|
1390
|
+
const textBaseline = options.textBaseline;
|
|
1391
|
+
const videoElement = options.videoElement;
|
|
1392
|
+
const videoHeight = options.videoHeight;
|
|
1393
|
+
const videoWidth = options.videoWidth;
|
|
1394
|
+
const webcamVideoElement = options.webcamVideoElement;
|
|
1395
|
+
const gifWidth = Number(options.gifWidth);
|
|
1396
|
+
const gifHeight = Number(options.gifHeight);
|
|
1397
|
+
let interval = Number(options.interval);
|
|
1398
|
+
const sampleInterval = Number(options.sampleInterval);
|
|
1399
|
+
const waitBetweenFrames = hasExistingImages ? 0 : interval * 1000;
|
|
1400
|
+
const renderingContextsToSave = [];
|
|
1401
|
+
let numFrames = savedRenderingContexts.length ? savedRenderingContexts.length : options.numFrames;
|
|
1402
|
+
let pendingFrames = numFrames;
|
|
1403
|
+
const ag = new AnimatedGIF(options);
|
|
1404
|
+
const fontSize = utils.getFontSize(options);
|
|
1405
|
+
const textXCoordinate = options.textXCoordinate ? options.textXCoordinate : textAlign === 'left' ? 1 : textAlign === 'right' ? gifWidth : gifWidth / 2;
|
|
1406
|
+
const textYCoordinate = options.textYCoordinate ? options.textYCoordinate : textBaseline === 'top' ? 1 : textBaseline === 'center' ? gifHeight / 2 : gifHeight;
|
|
1407
|
+
const font = "".concat(fontWeight, " ").concat(fontSize, " ").concat(fontFamily);
|
|
1408
|
+
let sourceX = crop ? Math.floor(crop.scaledWidth / 2) : 0;
|
|
1409
|
+
let sourceWidth = crop ? videoWidth - crop.scaledWidth : 0;
|
|
1410
|
+
let sourceY = crop ? Math.floor(crop.scaledHeight / 2) : 0;
|
|
1411
|
+
let sourceHeight = crop ? videoHeight - crop.scaledHeight : 0;
|
|
1412
|
+
const captureFrames = function captureSingleFrame() {
|
|
1413
|
+
const framesLeft = pendingFrames - 1;
|
|
1416
1414
|
if (savedRenderingContexts.length) {
|
|
1417
1415
|
context.putImageData(savedRenderingContexts[numFrames - pendingFrames], 0, 0);
|
|
1418
1416
|
finishCapture();
|
|
@@ -1445,7 +1443,7 @@ var screenShot = {
|
|
|
1445
1443
|
}
|
|
1446
1444
|
}
|
|
1447
1445
|
function finishCapture() {
|
|
1448
|
-
|
|
1446
|
+
let imageData = void 0;
|
|
1449
1447
|
if (saveRenderingContexts) {
|
|
1450
1448
|
renderingContextsToSave.push(context.getImageData(0, 0, gifWidth, gifHeight));
|
|
1451
1449
|
}
|
|
@@ -1469,12 +1467,12 @@ var screenShot = {
|
|
|
1469
1467
|
error: false,
|
|
1470
1468
|
errorCode: '',
|
|
1471
1469
|
errorMsg: '',
|
|
1472
|
-
image
|
|
1473
|
-
cameraStream
|
|
1474
|
-
videoElement
|
|
1475
|
-
webcamVideoElement
|
|
1470
|
+
image,
|
|
1471
|
+
cameraStream,
|
|
1472
|
+
videoElement,
|
|
1473
|
+
webcamVideoElement,
|
|
1476
1474
|
savedRenderingContexts: renderingContextsToSave,
|
|
1477
|
-
keepCameraOn
|
|
1475
|
+
keepCameraOn
|
|
1478
1476
|
});
|
|
1479
1477
|
});
|
|
1480
1478
|
}
|
|
@@ -1494,12 +1492,12 @@ var screenShot = {
|
|
|
1494
1492
|
})();
|
|
1495
1493
|
},
|
|
1496
1494
|
getCropDimensions: function getCropDimensions() {
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1495
|
+
const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1496
|
+
const width = obj.videoWidth;
|
|
1497
|
+
const height = obj.videoHeight;
|
|
1498
|
+
const gifWidth = obj.gifWidth;
|
|
1499
|
+
const gifHeight = obj.gifHeight;
|
|
1500
|
+
const result = {
|
|
1503
1501
|
width: 0,
|
|
1504
1502
|
height: 0,
|
|
1505
1503
|
scaledWidth: 0,
|
|
@@ -1523,17 +1521,17 @@ var videoStream = {
|
|
|
1523
1521
|
},
|
|
1524
1522
|
findVideoSize: function findVideoSizeMethod(obj) {
|
|
1525
1523
|
findVideoSizeMethod.attempts = findVideoSizeMethod.attempts || 0;
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1524
|
+
const cameraStream = obj.cameraStream;
|
|
1525
|
+
const completedCallback = obj.completedCallback;
|
|
1526
|
+
const videoElement = obj.videoElement;
|
|
1529
1527
|
if (!videoElement) {
|
|
1530
1528
|
return;
|
|
1531
1529
|
}
|
|
1532
1530
|
if (videoElement.videoWidth > 0 && videoElement.videoHeight > 0) {
|
|
1533
1531
|
videoElement.removeEventListener('loadeddata', videoStream.findVideoSize);
|
|
1534
1532
|
completedCallback({
|
|
1535
|
-
videoElement
|
|
1536
|
-
cameraStream
|
|
1533
|
+
videoElement,
|
|
1534
|
+
cameraStream,
|
|
1537
1535
|
videoWidth: videoElement.videoWidth,
|
|
1538
1536
|
videoHeight: videoElement.videoHeight
|
|
1539
1537
|
});
|
|
@@ -1544,8 +1542,8 @@ var videoStream = {
|
|
|
1544
1542
|
}, 400);
|
|
1545
1543
|
} else {
|
|
1546
1544
|
completedCallback({
|
|
1547
|
-
videoElement
|
|
1548
|
-
cameraStream
|
|
1545
|
+
videoElement,
|
|
1546
|
+
cameraStream,
|
|
1549
1547
|
videoWidth: videoStream.defaultVideoDimensions.width,
|
|
1550
1548
|
videoHeight: videoStream.defaultVideoDimensions.height
|
|
1551
1549
|
});
|
|
@@ -1563,11 +1561,11 @@ var videoStream = {
|
|
|
1563
1561
|
}
|
|
1564
1562
|
},
|
|
1565
1563
|
stream: function stream(obj) {
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1564
|
+
const existingVideo = utils.isArray(obj.existingVideo) ? obj.existingVideo[0] : obj.existingVideo;
|
|
1565
|
+
const cameraStream = obj.cameraStream;
|
|
1566
|
+
const completedCallback = obj.completedCallback;
|
|
1567
|
+
const streamedCallback = obj.streamedCallback;
|
|
1568
|
+
const videoElement = obj.videoElement;
|
|
1571
1569
|
if (utils.isFunction(streamedCallback)) {
|
|
1572
1570
|
streamedCallback();
|
|
1573
1571
|
}
|
|
@@ -1596,18 +1594,18 @@ var videoStream = {
|
|
|
1596
1594
|
checkLoadedData.count = checkLoadedData.count || 0;
|
|
1597
1595
|
if (videoStream.loadedData === true) {
|
|
1598
1596
|
videoStream.findVideoSize({
|
|
1599
|
-
videoElement
|
|
1600
|
-
cameraStream
|
|
1601
|
-
completedCallback
|
|
1597
|
+
videoElement,
|
|
1598
|
+
cameraStream,
|
|
1599
|
+
completedCallback
|
|
1602
1600
|
});
|
|
1603
1601
|
videoStream.loadedData = false;
|
|
1604
1602
|
} else {
|
|
1605
1603
|
checkLoadedData.count += 1;
|
|
1606
1604
|
if (checkLoadedData.count > 10) {
|
|
1607
1605
|
videoStream.findVideoSize({
|
|
1608
|
-
videoElement
|
|
1609
|
-
cameraStream
|
|
1610
|
-
completedCallback
|
|
1606
|
+
videoElement,
|
|
1607
|
+
cameraStream,
|
|
1608
|
+
completedCallback
|
|
1611
1609
|
});
|
|
1612
1610
|
} else {
|
|
1613
1611
|
checkLoadedData();
|
|
@@ -1616,16 +1614,16 @@ var videoStream = {
|
|
|
1616
1614
|
}, 0);
|
|
1617
1615
|
},
|
|
1618
1616
|
startStreaming: function startStreaming(obj) {
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1617
|
+
const errorCallback = utils.isFunction(obj.error) ? obj.error : utils.noop;
|
|
1618
|
+
const streamedCallback = utils.isFunction(obj.streamed) ? obj.streamed : utils.noop;
|
|
1619
|
+
const completedCallback = utils.isFunction(obj.completed) ? obj.completed : utils.noop;
|
|
1620
|
+
const crossOrigin = obj.crossOrigin;
|
|
1621
|
+
const existingVideo = obj.existingVideo;
|
|
1622
|
+
const lastCameraStream = obj.lastCameraStream;
|
|
1623
|
+
const options = obj.options;
|
|
1624
|
+
const webcamVideoElement = obj.webcamVideoElement;
|
|
1625
|
+
const videoElement = utils.isElement(existingVideo) ? existingVideo : webcamVideoElement ? webcamVideoElement : document.createElement('video');
|
|
1626
|
+
const cameraStream = void 0;
|
|
1629
1627
|
if (crossOrigin) {
|
|
1630
1628
|
videoElement.crossOrigin = options.crossOrigin;
|
|
1631
1629
|
}
|
|
@@ -1640,36 +1638,36 @@ var videoStream = {
|
|
|
1640
1638
|
});
|
|
1641
1639
|
if (existingVideo) {
|
|
1642
1640
|
videoStream.stream({
|
|
1643
|
-
videoElement
|
|
1644
|
-
existingVideo
|
|
1645
|
-
completedCallback
|
|
1641
|
+
videoElement,
|
|
1642
|
+
existingVideo,
|
|
1643
|
+
completedCallback
|
|
1646
1644
|
});
|
|
1647
1645
|
} else if (lastCameraStream) {
|
|
1648
1646
|
videoStream.stream({
|
|
1649
|
-
videoElement
|
|
1647
|
+
videoElement,
|
|
1650
1648
|
cameraStream: lastCameraStream,
|
|
1651
|
-
streamedCallback
|
|
1652
|
-
completedCallback
|
|
1649
|
+
streamedCallback,
|
|
1650
|
+
completedCallback
|
|
1653
1651
|
});
|
|
1654
1652
|
} else {
|
|
1655
1653
|
utils.getUserMedia({
|
|
1656
1654
|
video: true
|
|
1657
1655
|
}, function (stream) {
|
|
1658
1656
|
videoStream.stream({
|
|
1659
|
-
videoElement
|
|
1657
|
+
videoElement,
|
|
1660
1658
|
cameraStream: stream,
|
|
1661
|
-
streamedCallback
|
|
1662
|
-
completedCallback
|
|
1659
|
+
streamedCallback,
|
|
1660
|
+
completedCallback
|
|
1663
1661
|
});
|
|
1664
1662
|
}, errorCallback);
|
|
1665
1663
|
}
|
|
1666
1664
|
},
|
|
1667
1665
|
startVideoStreaming: function startVideoStreaming(callback) {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1666
|
+
const options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1667
|
+
const timeoutLength = options.timeout !== undefined ? options.timeout : 0;
|
|
1668
|
+
const originalCallback = options.callback;
|
|
1669
|
+
const webcamVideoElement = options.webcamVideoElement;
|
|
1670
|
+
let noGetUserMediaSupportTimeout = void 0;
|
|
1673
1671
|
if (timeoutLength > 0) {
|
|
1674
1672
|
noGetUserMediaSupportTimeout = utils.requestTimeout(function () {
|
|
1675
1673
|
videoStream.onStreamingTimeout(originalCallback);
|
|
@@ -1689,34 +1687,34 @@ var videoStream = {
|
|
|
1689
1687
|
clearTimeout(noGetUserMediaSupportTimeout);
|
|
1690
1688
|
},
|
|
1691
1689
|
completed: function completed() {
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1690
|
+
const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1691
|
+
const cameraStream = obj.cameraStream;
|
|
1692
|
+
const videoElement = obj.videoElement;
|
|
1693
|
+
const videoHeight = obj.videoHeight;
|
|
1694
|
+
const videoWidth = obj.videoWidth;
|
|
1697
1695
|
callback({
|
|
1698
|
-
cameraStream
|
|
1699
|
-
videoElement
|
|
1700
|
-
videoHeight
|
|
1701
|
-
videoWidth
|
|
1696
|
+
cameraStream,
|
|
1697
|
+
videoElement,
|
|
1698
|
+
videoHeight,
|
|
1699
|
+
videoWidth
|
|
1702
1700
|
});
|
|
1703
1701
|
},
|
|
1704
1702
|
lastCameraStream: options.lastCameraStream,
|
|
1705
|
-
webcamVideoElement
|
|
1703
|
+
webcamVideoElement,
|
|
1706
1704
|
crossOrigin: options.crossOrigin,
|
|
1707
|
-
options
|
|
1705
|
+
options
|
|
1708
1706
|
});
|
|
1709
1707
|
},
|
|
1710
1708
|
stopVideoStreaming: function stopVideoStreaming(obj) {
|
|
1711
1709
|
obj = utils.isObject(obj) ? obj : {};
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1710
|
+
const _obj = obj;
|
|
1711
|
+
const keepCameraOn = _obj.keepCameraOn;
|
|
1712
|
+
const videoElement = _obj.videoElement;
|
|
1713
|
+
const webcamVideoElement = _obj.webcamVideoElement;
|
|
1714
|
+
const cameraStream = obj.cameraStream || {};
|
|
1715
|
+
const cameraStreamTracks = cameraStream.getTracks ? cameraStream.getTracks() || [] : [];
|
|
1716
|
+
const hasCameraStreamTracks = Boolean(cameraStreamTracks.length);
|
|
1717
|
+
const firstCameraStreamTrack = cameraStreamTracks[0];
|
|
1720
1718
|
if (!keepCameraOn && hasCameraStreamTracks) {
|
|
1721
1719
|
if (utils.isFunction(firstCameraStreamTrack.stop)) {
|
|
1722
1720
|
firstCameraStreamTrack.stop();
|
|
@@ -1738,23 +1736,23 @@ function stopVideoStreaming(options) {
|
|
|
1738
1736
|
videoStream.stopVideoStreaming(options);
|
|
1739
1737
|
}
|
|
1740
1738
|
function createAndGetGIF(obj, callback) {
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
videoWidth
|
|
1753
|
-
videoHeight
|
|
1754
|
-
gifHeight
|
|
1755
|
-
gifWidth
|
|
1739
|
+
const options = obj.options || {};
|
|
1740
|
+
const images = options.images;
|
|
1741
|
+
const video = options.video;
|
|
1742
|
+
const gifWidth = Number(options.gifWidth);
|
|
1743
|
+
const gifHeight = Number(options.gifHeight);
|
|
1744
|
+
const numFrames = Number(options.numFrames);
|
|
1745
|
+
const cameraStream = obj.cameraStream;
|
|
1746
|
+
const videoElement = obj.videoElement;
|
|
1747
|
+
const videoWidth = obj.videoWidth;
|
|
1748
|
+
const videoHeight = obj.videoHeight;
|
|
1749
|
+
const cropDimensions = screenShot.getCropDimensions({
|
|
1750
|
+
videoWidth,
|
|
1751
|
+
videoHeight,
|
|
1752
|
+
gifHeight,
|
|
1753
|
+
gifWidth
|
|
1756
1754
|
});
|
|
1757
|
-
|
|
1755
|
+
const completeCallback = callback;
|
|
1758
1756
|
options.crop = cropDimensions;
|
|
1759
1757
|
options.videoElement = videoElement;
|
|
1760
1758
|
options.videoWidth = videoWidth;
|
|
@@ -1781,20 +1779,20 @@ function createAndGetGIF(obj, callback) {
|
|
|
1781
1779
|
});
|
|
1782
1780
|
}
|
|
1783
1781
|
function existingVideo() {
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1782
|
+
const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1783
|
+
const callback = obj.callback;
|
|
1784
|
+
let existingVideo = obj.existingVideo;
|
|
1785
|
+
const options = obj.options;
|
|
1786
|
+
const skipObj = {
|
|
1789
1787
|
getUserMedia: true,
|
|
1790
1788
|
'globalThis.URL': true
|
|
1791
1789
|
};
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1790
|
+
const errorObj = error.validate(skipObj);
|
|
1791
|
+
const loadedImages = 0;
|
|
1792
|
+
let videoType = void 0;
|
|
1793
|
+
let videoSrc = void 0;
|
|
1794
|
+
const tempImage = void 0;
|
|
1795
|
+
const ag = void 0;
|
|
1798
1796
|
if (errorObj.error) {
|
|
1799
1797
|
return callback(errorObj);
|
|
1800
1798
|
}
|
|
@@ -1822,17 +1820,17 @@ function existingVideo() {
|
|
|
1822
1820
|
obj.options = options || {};
|
|
1823
1821
|
createAndGetGIF(obj, callback);
|
|
1824
1822
|
},
|
|
1825
|
-
existingVideo
|
|
1823
|
+
existingVideo,
|
|
1826
1824
|
crossOrigin: options.crossOrigin,
|
|
1827
|
-
options
|
|
1825
|
+
options
|
|
1828
1826
|
});
|
|
1829
1827
|
}
|
|
1830
1828
|
function existingWebcam() {
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1829
|
+
const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1830
|
+
const callback = obj.callback;
|
|
1831
|
+
const lastCameraStream = obj.lastCameraStream;
|
|
1832
|
+
const options = obj.options;
|
|
1833
|
+
const webcamVideoElement = obj.webcamVideoElement;
|
|
1836
1834
|
if (!isWebCamGIFSupported()) {
|
|
1837
1835
|
return callback(error.validate());
|
|
1838
1836
|
}
|
|
@@ -1843,13 +1841,13 @@ function existingWebcam() {
|
|
|
1843
1841
|
return;
|
|
1844
1842
|
}
|
|
1845
1843
|
videoStream.startVideoStreaming(function () {
|
|
1846
|
-
|
|
1844
|
+
const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1847
1845
|
obj.options = options || {};
|
|
1848
1846
|
createAndGetGIF(obj, callback);
|
|
1849
1847
|
}, {
|
|
1850
|
-
lastCameraStream
|
|
1851
|
-
callback
|
|
1852
|
-
webcamVideoElement
|
|
1848
|
+
lastCameraStream,
|
|
1849
|
+
callback,
|
|
1850
|
+
webcamVideoElement,
|
|
1853
1851
|
crossOrigin: options.crossOrigin
|
|
1854
1852
|
});
|
|
1855
1853
|
}
|
|
@@ -1859,35 +1857,35 @@ function createGIF(userOptions, callback) {
|
|
|
1859
1857
|
if (!utils.isFunction(callback)) {
|
|
1860
1858
|
return;
|
|
1861
1859
|
}
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1860
|
+
let options = utils.normalizeOptions(defaultOptions, userOptions) || {};
|
|
1861
|
+
const lastCameraStream = userOptions.cameraStream;
|
|
1862
|
+
const images = options.images;
|
|
1863
|
+
const imagesLength = images ? images.length : 0;
|
|
1864
|
+
const video = options.video;
|
|
1865
|
+
const webcamVideoElement = options.webcamVideoElement;
|
|
1868
1866
|
options = utils.normalizeOptions(options, {
|
|
1869
1867
|
gifWidth: Math.floor(options.gifWidth),
|
|
1870
1868
|
gifHeight: Math.floor(options.gifHeight)
|
|
1871
1869
|
});
|
|
1872
1870
|
if (imagesLength) {
|
|
1873
1871
|
existingImages({
|
|
1874
|
-
images
|
|
1875
|
-
imagesLength
|
|
1876
|
-
callback
|
|
1877
|
-
options
|
|
1872
|
+
images,
|
|
1873
|
+
imagesLength,
|
|
1874
|
+
callback,
|
|
1875
|
+
options
|
|
1878
1876
|
});
|
|
1879
1877
|
} else if (video) {
|
|
1880
1878
|
existingVideo({
|
|
1881
1879
|
existingVideo: video,
|
|
1882
|
-
callback
|
|
1883
|
-
options
|
|
1880
|
+
callback,
|
|
1881
|
+
options
|
|
1884
1882
|
});
|
|
1885
1883
|
} else {
|
|
1886
1884
|
existingWebcam({
|
|
1887
|
-
lastCameraStream
|
|
1888
|
-
callback
|
|
1889
|
-
webcamVideoElement
|
|
1890
|
-
options
|
|
1885
|
+
lastCameraStream,
|
|
1886
|
+
callback,
|
|
1887
|
+
webcamVideoElement,
|
|
1888
|
+
options
|
|
1891
1889
|
});
|
|
1892
1890
|
}
|
|
1893
1891
|
}
|
|
@@ -1897,8 +1895,8 @@ function takeSnapShot(userOptions, callback) {
|
|
|
1897
1895
|
if (!utils.isFunction(callback)) {
|
|
1898
1896
|
return;
|
|
1899
1897
|
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1898
|
+
const mergedOptions = utils.normalizeOptions(defaultOptions, userOptions);
|
|
1899
|
+
const options = utils.normalizeOptions(mergedOptions, {
|
|
1902
1900
|
interval: 0.1,
|
|
1903
1901
|
numFrames: 1,
|
|
1904
1902
|
gifWidth: Math.floor(mergedOptions.gifWidth),
|
|
@@ -1906,16 +1904,16 @@ function takeSnapShot(userOptions, callback) {
|
|
|
1906
1904
|
});
|
|
1907
1905
|
createGIF(options, callback);
|
|
1908
1906
|
}
|
|
1909
|
-
|
|
1907
|
+
const API = {
|
|
1910
1908
|
utils: utils$2,
|
|
1911
1909
|
error: error$2,
|
|
1912
1910
|
defaultOptions: defaultOptions$2,
|
|
1913
|
-
createGIF
|
|
1914
|
-
takeSnapShot
|
|
1915
|
-
stopVideoStreaming
|
|
1916
|
-
isSupported
|
|
1917
|
-
isWebCamGIFSupported
|
|
1918
|
-
isExistingVideoGIFSupported
|
|
1911
|
+
createGIF,
|
|
1912
|
+
takeSnapShot,
|
|
1913
|
+
stopVideoStreaming,
|
|
1914
|
+
isSupported,
|
|
1915
|
+
isWebCamGIFSupported,
|
|
1916
|
+
isExistingVideoGIFSupported,
|
|
1919
1917
|
isExistingImagesGIFSupported: isSupported$1,
|
|
1920
1918
|
VERSION: '0.4.5'
|
|
1921
1919
|
};
|