WIP - add extractor, generate snippet_data

This commit is contained in:
Stefan Fejes
2019-08-20 15:52:05 +02:00
parent 88084d3d30
commit cc8f1d8a7a
37396 changed files with 4588842 additions and 133 deletions

189
node_modules/@jimp/core/es/composite/composite-modes.js generated vendored Normal file
View File

@ -0,0 +1,189 @@
export function srcOver(src, dst) {
var ops = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
src.a *= ops;
var a = dst.a + src.a - dst.a * src.a;
var r = (src.r * src.a + dst.r * dst.a * (1 - src.a)) / a;
var g = (src.g * src.a + dst.g * dst.a * (1 - src.a)) / a;
var b = (src.b * src.a + dst.b * dst.a * (1 - src.a)) / a;
return {
r: r,
g: g,
b: b,
a: a
};
}
export function dstOver(src, dst) {
var ops = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
src.a *= ops;
var a = dst.a + src.a - dst.a * src.a;
var r = (dst.r * dst.a + src.r * src.a * (1 - dst.a)) / a;
var g = (dst.g * dst.a + src.g * src.a * (1 - dst.a)) / a;
var b = (dst.b * dst.a + src.b * src.a * (1 - dst.a)) / a;
return {
r: r,
g: g,
b: b,
a: a
};
}
export function multiply(src, dst) {
var ops = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
src.a *= ops;
var a = dst.a + src.a - dst.a * src.a;
var sra = src.r * src.a;
var sga = src.g * src.a;
var sba = src.b * src.a;
var dra = dst.r * dst.a;
var dga = dst.g * dst.a;
var dba = dst.b * dst.a;
var r = (sra * dra + sra * (1 - dst.a) + dra * (1 - src.a)) / a;
var g = (sga * dga + sga * (1 - dst.a) + dga * (1 - src.a)) / a;
var b = (sba * dba + sba * (1 - dst.a) + dba * (1 - src.a)) / a;
return {
r: r,
g: g,
b: b,
a: a
};
}
export function screen(src, dst) {
var ops = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
src.a *= ops;
var a = dst.a + src.a - dst.a * src.a;
var sra = src.r * src.a;
var sga = src.g * src.a;
var sba = src.b * src.a;
var dra = dst.r * dst.a;
var dga = dst.g * dst.a;
var dba = dst.b * dst.a;
var r = (sra * dst.a + dra * src.a - sra * dra + sra * (1 - dst.a) + dra * (1 - src.a)) / a;
var g = (sga * dst.a + dga * src.a - sga * dga + sga * (1 - dst.a) + dga * (1 - src.a)) / a;
var b = (sba * dst.a + dba * src.a - sba * dba + sba * (1 - dst.a) + dba * (1 - src.a)) / a;
return {
r: r,
g: g,
b: b,
a: a
};
}
export function overlay(src, dst) {
var ops = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
src.a *= ops;
var a = dst.a + src.a - dst.a * src.a;
var sra = src.r * src.a;
var sga = src.g * src.a;
var sba = src.b * src.a;
var dra = dst.r * dst.a;
var dga = dst.g * dst.a;
var dba = dst.b * dst.a;
var r = (2 * dra <= dst.a ? 2 * sra * dra + sra * (1 - dst.a) + dra * (1 - src.a) : sra * (1 + dst.a) + dra * (1 + src.a) - 2 * dra * sra - dst.a * src.a) / a;
var g = (2 * dga <= dst.a ? 2 * sga * dga + sga * (1 - dst.a) + dga * (1 - src.a) : sga * (1 + dst.a) + dga * (1 + src.a) - 2 * dga * sga - dst.a * src.a) / a;
var b = (2 * dba <= dst.a ? 2 * sba * dba + sba * (1 - dst.a) + dba * (1 - src.a) : sba * (1 + dst.a) + dba * (1 + src.a) - 2 * dba * sba - dst.a * src.a) / a;
return {
r: r,
g: g,
b: b,
a: a
};
}
export function darken(src, dst) {
var ops = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
src.a *= ops;
var a = dst.a + src.a - dst.a * src.a;
var sra = src.r * src.a;
var sga = src.g * src.a;
var sba = src.b * src.a;
var dra = dst.r * dst.a;
var dga = dst.g * dst.a;
var dba = dst.b * dst.a;
var r = (Math.min(sra * dst.a, dra * src.a) + sra * (1 - dst.a) + dra * (1 - src.a)) / a;
var g = (Math.min(sga * dst.a, dga * src.a) + sga * (1 - dst.a) + dga * (1 - src.a)) / a;
var b = (Math.min(sba * dst.a, dba * src.a) + sba * (1 - dst.a) + dba * (1 - src.a)) / a;
return {
r: r,
g: g,
b: b,
a: a
};
}
export function lighten(src, dst) {
var ops = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
src.a *= ops;
var a = dst.a + src.a - dst.a * src.a;
var sra = src.r * src.a;
var sga = src.g * src.a;
var sba = src.b * src.a;
var dra = dst.r * dst.a;
var dga = dst.g * dst.a;
var dba = dst.b * dst.a;
var r = (Math.max(sra * dst.a, dra * src.a) + sra * (1 - dst.a) + dra * (1 - src.a)) / a;
var g = (Math.max(sga * dst.a, dga * src.a) + sga * (1 - dst.a) + dga * (1 - src.a)) / a;
var b = (Math.max(sba * dst.a, dba * src.a) + sba * (1 - dst.a) + dba * (1 - src.a)) / a;
return {
r: r,
g: g,
b: b,
a: a
};
}
export function hardLight(src, dst) {
var ops = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
src.a *= ops;
var a = dst.a + src.a - dst.a * src.a;
var sra = src.r * src.a;
var sga = src.g * src.a;
var sba = src.b * src.a;
var dra = dst.r * dst.a;
var dga = dst.g * dst.a;
var dba = dst.b * dst.a;
var r = (2 * sra <= src.a ? 2 * sra * dra + sra * (1 - dst.a) + dra * (1 - src.a) : sra * (1 + dst.a) + dra * (1 + src.a) - 2 * dra * sra - dst.a * src.a) / a;
var g = (2 * sga <= src.a ? 2 * sga * dga + sga * (1 - dst.a) + dga * (1 - src.a) : sga * (1 + dst.a) + dga * (1 + src.a) - 2 * dga * sga - dst.a * src.a) / a;
var b = (2 * sba <= src.a ? 2 * sba * dba + sba * (1 - dst.a) + dba * (1 - src.a) : sba * (1 + dst.a) + dba * (1 + src.a) - 2 * dba * sba - dst.a * src.a) / a;
return {
r: r,
g: g,
b: b,
a: a
};
}
export function difference(src, dst) {
var ops = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
src.a *= ops;
var a = dst.a + src.a - dst.a * src.a;
var sra = src.r * src.a;
var sga = src.g * src.a;
var sba = src.b * src.a;
var dra = dst.r * dst.a;
var dga = dst.g * dst.a;
var dba = dst.b * dst.a;
var r = (sra + dra - 2 * Math.min(sra * dst.a, dra * src.a)) / a;
var g = (sga + dga - 2 * Math.min(sga * dst.a, dga * src.a)) / a;
var b = (sba + dba - 2 * Math.min(sba * dst.a, dba * src.a)) / a;
return {
r: r,
g: g,
b: b,
a: a
};
}
export function exclusion(src, dst) {
var ops = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
src.a *= ops;
var a = dst.a + src.a - dst.a * src.a;
var sra = src.r * src.a;
var sga = src.g * src.a;
var sba = src.b * src.a;
var dra = dst.r * dst.a;
var dga = dst.g * dst.a;
var dba = dst.b * dst.a;
var r = (sra * dst.a + dra * src.a - 2 * sra * dra + sra * (1 - dst.a) + dra * (1 - src.a)) / a;
var g = (sga * dst.a + dga * src.a - 2 * sga * dga + sga * (1 - dst.a) + dga * (1 - src.a)) / a;
var b = (sba * dst.a + dba * src.a - 2 * sba * dba + sba * (1 - dst.a) + dba * (1 - src.a)) / a;
return {
r: r,
g: g,
b: b,
a: a
};
}
//# sourceMappingURL=composite-modes.js.map

File diff suppressed because one or more lines are too long

83
node_modules/@jimp/core/es/composite/index.js generated vendored Normal file
View File

@ -0,0 +1,83 @@
import { isNodePattern, throwError } from '@jimp/utils';
import * as constants from '../constants';
import * as compositeModes from './composite-modes';
/**
* Composites a source image over to this image respecting alpha channels
* @param {Jimp} src the source Jimp instance
* @param {number} x the x position to blit the image
* @param {number} y the y position to blit the image
* @param {object} options determine what mode to use
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
export default function composite(src, x, y) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var cb = arguments.length > 4 ? arguments[4] : undefined;
if (typeof options === 'function') {
cb = options;
options = {};
}
if (!(src instanceof this.constructor)) {
return throwError.call(this, 'The source must be a Jimp image', cb);
}
if (typeof x !== 'number' || typeof y !== 'number') {
return throwError.call(this, 'x and y must be numbers', cb);
}
var _options = options,
mode = _options.mode,
opacitySource = _options.opacitySource,
opacityDest = _options.opacityDest;
if (!mode) {
mode = constants.BLEND_SOURCE_OVER;
}
if (typeof opacitySource !== 'number' || opacitySource < 0 || opacitySource > 1) {
opacitySource = 1.0;
}
if (typeof opacityDest !== 'number' || opacityDest < 0 || opacityDest > 1) {
opacityDest = 1.0;
}
var blendmode = compositeModes[mode]; // round input
x = Math.round(x);
y = Math.round(y);
var baseImage = this;
if (opacityDest !== 1.0) {
baseImage.opacity(opacityDest);
}
src.scanQuiet(0, 0, src.bitmap.width, src.bitmap.height, function (sx, sy, idx) {
var dstIdx = baseImage.getPixelIndex(x + sx, y + sy, constants.EDGE_CROP);
var blended = blendmode({
r: this.bitmap.data[idx + 0] / 255,
g: this.bitmap.data[idx + 1] / 255,
b: this.bitmap.data[idx + 2] / 255,
a: this.bitmap.data[idx + 3] / 255
}, {
r: baseImage.bitmap.data[dstIdx + 0] / 255,
g: baseImage.bitmap.data[dstIdx + 1] / 255,
b: baseImage.bitmap.data[dstIdx + 2] / 255,
a: baseImage.bitmap.data[dstIdx + 3] / 255
}, opacitySource);
baseImage.bitmap.data[dstIdx + 0] = this.constructor.limit255(blended.r * 255);
baseImage.bitmap.data[dstIdx + 1] = this.constructor.limit255(blended.g * 255);
baseImage.bitmap.data[dstIdx + 2] = this.constructor.limit255(blended.b * 255);
baseImage.bitmap.data[dstIdx + 3] = this.constructor.limit255(blended.a * 255);
});
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
return this;
}
//# sourceMappingURL=index.js.map

1
node_modules/@jimp/core/es/composite/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

25
node_modules/@jimp/core/es/constants.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
// used to auto resizing etc.
export var AUTO = -1; // Align modes for cover, contain, bit masks
export var HORIZONTAL_ALIGN_LEFT = 1;
export var HORIZONTAL_ALIGN_CENTER = 2;
export var HORIZONTAL_ALIGN_RIGHT = 4;
export var VERTICAL_ALIGN_TOP = 8;
export var VERTICAL_ALIGN_MIDDLE = 16;
export var VERTICAL_ALIGN_BOTTOM = 32; // blend modes
export var BLEND_SOURCE_OVER = 'srcOver';
export var BLEND_DESTINATION_OVER = 'dstOver';
export var BLEND_MULTIPLY = 'multiply';
export var BLEND_SCREEN = 'screen';
export var BLEND_OVERLAY = 'overlay';
export var BLEND_DARKEN = 'darken';
export var BLEND_LIGHTEN = 'lighten';
export var BLEND_HARDLIGHT = 'hardLight';
export var BLEND_DIFFERENCE = 'difference';
export var BLEND_EXCLUSION = 'exclusion'; // Edge Handling
export var EDGE_EXTEND = 1;
export var EDGE_WRAP = 2;
export var EDGE_CROP = 3;
//# sourceMappingURL=constants.js.map

1
node_modules/@jimp/core/es/constants.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../src/constants.js"],"names":["AUTO","HORIZONTAL_ALIGN_LEFT","HORIZONTAL_ALIGN_CENTER","HORIZONTAL_ALIGN_RIGHT","VERTICAL_ALIGN_TOP","VERTICAL_ALIGN_MIDDLE","VERTICAL_ALIGN_BOTTOM","BLEND_SOURCE_OVER","BLEND_DESTINATION_OVER","BLEND_MULTIPLY","BLEND_SCREEN","BLEND_OVERLAY","BLEND_DARKEN","BLEND_LIGHTEN","BLEND_HARDLIGHT","BLEND_DIFFERENCE","BLEND_EXCLUSION","EDGE_EXTEND","EDGE_WRAP","EDGE_CROP"],"mappings":"AAAA;AACA,OAAO,IAAMA,IAAI,GAAG,CAAC,CAAd,C,CAEP;;AACA,OAAO,IAAMC,qBAAqB,GAAG,CAA9B;AACP,OAAO,IAAMC,uBAAuB,GAAG,CAAhC;AACP,OAAO,IAAMC,sBAAsB,GAAG,CAA/B;AAEP,OAAO,IAAMC,kBAAkB,GAAG,CAA3B;AACP,OAAO,IAAMC,qBAAqB,GAAG,EAA9B;AACP,OAAO,IAAMC,qBAAqB,GAAG,EAA9B,C,CAEP;;AACA,OAAO,IAAMC,iBAAiB,GAAG,SAA1B;AACP,OAAO,IAAMC,sBAAsB,GAAG,SAA/B;AACP,OAAO,IAAMC,cAAc,GAAG,UAAvB;AACP,OAAO,IAAMC,YAAY,GAAG,QAArB;AACP,OAAO,IAAMC,aAAa,GAAG,SAAtB;AACP,OAAO,IAAMC,YAAY,GAAG,QAArB;AACP,OAAO,IAAMC,aAAa,GAAG,SAAtB;AACP,OAAO,IAAMC,eAAe,GAAG,WAAxB;AACP,OAAO,IAAMC,gBAAgB,GAAG,YAAzB;AACP,OAAO,IAAMC,eAAe,GAAG,WAAxB,C,CAEP;;AACA,OAAO,IAAMC,WAAW,GAAG,CAApB;AACP,OAAO,IAAMC,SAAS,GAAG,CAAlB;AACP,OAAO,IAAMC,SAAS,GAAG,CAAlB","sourcesContent":["// used to auto resizing etc.\nexport const AUTO = -1;\n\n// Align modes for cover, contain, bit masks\nexport const HORIZONTAL_ALIGN_LEFT = 1;\nexport const HORIZONTAL_ALIGN_CENTER = 2;\nexport const HORIZONTAL_ALIGN_RIGHT = 4;\n\nexport const VERTICAL_ALIGN_TOP = 8;\nexport const VERTICAL_ALIGN_MIDDLE = 16;\nexport const VERTICAL_ALIGN_BOTTOM = 32;\n\n// blend modes\nexport const BLEND_SOURCE_OVER = 'srcOver';\nexport const BLEND_DESTINATION_OVER = 'dstOver';\nexport const BLEND_MULTIPLY = 'multiply';\nexport const BLEND_SCREEN = 'screen';\nexport const BLEND_OVERLAY = 'overlay';\nexport const BLEND_DARKEN = 'darken';\nexport const BLEND_LIGHTEN = 'lighten';\nexport const BLEND_HARDLIGHT = 'hardLight';\nexport const BLEND_DIFFERENCE = 'difference';\nexport const BLEND_EXCLUSION = 'exclusion';\n\n// Edge Handling\nexport const EDGE_EXTEND = 1;\nexport const EDGE_WRAP = 2;\nexport const EDGE_CROP = 3;\n"],"file":"constants.js"}

1249
node_modules/@jimp/core/es/index.js generated vendored Executable file

File diff suppressed because it is too large Load Diff

1
node_modules/@jimp/core/es/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

171
node_modules/@jimp/core/es/modules/phash.js generated vendored Normal file
View File

@ -0,0 +1,171 @@
/*
Copyright (c) 2011 Elliot Shepherd
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.
*/
// https://code.google.com/p/ironchef-team21/source/browse/ironchef_team21/src/ImagePHash.java
/*
* pHash-like image hash.
* Author: Elliot Shepherd (elliot@jarofworms.com
* Based On: http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html
*/
function ImagePHash(size, smallerSize) {
this.size = this.size || size;
this.smallerSize = this.smallerSize || smallerSize;
initCoefficients(this.size);
}
ImagePHash.prototype.size = 32;
ImagePHash.prototype.smallerSize = 8;
ImagePHash.prototype.distance = function (s1, s2) {
var counter = 0;
for (var k = 0; k < s1.length; k++) {
if (s1[k] !== s2[k]) {
counter++;
}
}
return counter / s1.length;
}; // Returns a 'binary string' (like. 001010111011100010) which is easy to do a hamming distance on.
ImagePHash.prototype.getHash = function (img) {
/* 1. Reduce size.
* Like Average Hash, pHash starts with a small image.
* However, the image is larger than 8x8; 32x32 is a good size.
* This is really done to simplify the DCT computation and not
* because it is needed to reduce the high frequencies.
*/
img = img.clone().resize(this.size, this.size);
/* 2. Reduce color.
* The image is reduced to a grayscale just to further simplify
* the number of computations.
*/
img.grayscale();
var vals = [];
for (var x = 0; x < img.bitmap.width; x++) {
vals[x] = [];
for (var y = 0; y < img.bitmap.height; y++) {
vals[x][y] = intToRGBA(img.getPixelColor(x, y)).b;
}
}
/* 3. Compute the DCT.
* The DCT separates the image into a collection of frequencies
* and scalars. While JPEG uses an 8x8 DCT, this algorithm uses
* a 32x32 DCT.
*/
var dctVals = applyDCT(vals, this.size);
/* 4. Reduce the DCT.
* This is the magic step. While the DCT is 32x32, just keep the
* top-left 8x8. Those represent the lowest frequencies in the
* picture.
*/
/* 5. Compute the average value.
* Like the Average Hash, compute the mean DCT value (using only
* the 8x8 DCT low-frequency values and excluding the first term
* since the DC coefficient can be significantly different from
* the other values and will throw off the average).
*/
var total = 0;
for (var _x = 0; _x < this.smallerSize; _x++) {
for (var _y = 0; _y < this.smallerSize; _y++) {
total += dctVals[_x][_y];
}
}
var avg = total / (this.smallerSize * this.smallerSize);
/* 6. Further reduce the DCT.
* This is the magic step. Set the 64 hash bits to 0 or 1
* depending on whether each of the 64 DCT values is above or
* below the average value. The result doesn't tell us the
* actual low frequencies; it just tells us the very-rough
* relative scale of the frequencies to the mean. The result
* will not vary as long as the overall structure of the image
* remains the same; this can survive gamma and color histogram
* adjustments without a problem.
*/
var hash = '';
for (var _x2 = 0; _x2 < this.smallerSize; _x2++) {
for (var _y2 = 0; _y2 < this.smallerSize; _y2++) {
hash += dctVals[_x2][_y2] > avg ? '1' : '0';
}
}
return hash;
}; // DCT function stolen from http://stackoverflow.com/questions/4240490/problems-with-dct-and-idct-algorithm-in-java
function intToRGBA(i) {
var rgba = {};
rgba.r = Math.floor(i / Math.pow(256, 3));
rgba.g = Math.floor((i - rgba.r * Math.pow(256, 3)) / Math.pow(256, 2));
rgba.b = Math.floor((i - rgba.r * Math.pow(256, 3) - rgba.g * Math.pow(256, 2)) / Math.pow(256, 1));
rgba.a = Math.floor((i - rgba.r * Math.pow(256, 3) - rgba.g * Math.pow(256, 2) - rgba.b * Math.pow(256, 1)) / Math.pow(256, 0));
return rgba;
}
var c = [];
function initCoefficients(size) {
for (var i = 1; i < size; i++) {
c[i] = 1;
}
c[0] = 1 / Math.sqrt(2.0);
}
function applyDCT(f, size) {
var N = size;
var F = [];
for (var u = 0; u < N; u++) {
F[u] = [];
for (var v = 0; v < N; v++) {
var sum = 0;
for (var i = 0; i < N; i++) {
for (var j = 0; j < N; j++) {
sum += Math.cos((2 * i + 1) / (2.0 * N) * u * Math.PI) * Math.cos((2 * j + 1) / (2.0 * N) * v * Math.PI) * f[i][j];
}
}
sum *= c[u] * c[v] / 4;
F[u][v] = sum;
}
}
return F;
}
module.exports = ImagePHash;
//# sourceMappingURL=phash.js.map

1
node_modules/@jimp/core/es/modules/phash.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

49
node_modules/@jimp/core/es/request.js generated vendored Normal file
View File

@ -0,0 +1,49 @@
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
/* global XMLHttpRequest */
if (process.browser || process.env.ENVIRONMENT === 'BROWSER' || typeof process.versions.electron !== 'undefined' && process.type === 'renderer' && typeof XMLHttpRequest === 'function') {
// If we run into a browser or the electron renderer process,
// use XHR method instead of Request node module.
module.exports = function (options, cb) {
var xhr = new XMLHttpRequest();
xhr.open('GET', options.url, true);
xhr.responseType = 'arraybuffer';
xhr.addEventListener('load', function () {
if (xhr.status < 400) {
try {
var data = Buffer.from(this.response);
cb(null, xhr, data);
} catch (error) {
return cb(new Error('Response is not a buffer for url ' + options.url + '. Error: ' + error.message));
}
} else {
cb(new Error('HTTP Status ' + xhr.status + ' for url ' + options.url));
}
});
xhr.addEventListener('error', function (e) {
cb(e);
});
xhr.send();
};
} else {
module.exports = function (_ref, cb) {
var options = _extends({}, _ref);
var p = require('phin');
p(_objectSpread({
compression: true
}, options), function (err, res) {
if (err === null) {
cb(null, res, res.body);
} else {
cb(err);
}
});
};
}
//# sourceMappingURL=request.js.map

1
node_modules/@jimp/core/es/request.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../src/request.js"],"names":["process","browser","env","ENVIRONMENT","versions","electron","type","XMLHttpRequest","module","exports","options","cb","xhr","open","url","responseType","addEventListener","status","data","Buffer","from","response","error","Error","message","e","send","p","require","compression","err","res","body"],"mappings":";;;;;;AAAA;AAEA,IACEA,OAAO,CAACC,OAAR,IACAD,OAAO,CAACE,GAAR,CAAYC,WAAZ,KAA4B,SAD5B,IAEC,OAAOH,OAAO,CAACI,QAAR,CAAiBC,QAAxB,KAAqC,WAArC,IACCL,OAAO,CAACM,IAAR,KAAiB,UADlB,IAEC,OAAOC,cAAP,KAA0B,UAL9B,EAME;AACA;AACA;AAEAC,EAAAA,MAAM,CAACC,OAAP,GAAiB,UAASC,OAAT,EAAkBC,EAAlB,EAAsB;AACrC,QAAMC,GAAG,GAAG,IAAIL,cAAJ,EAAZ;AACAK,IAAAA,GAAG,CAACC,IAAJ,CAAS,KAAT,EAAgBH,OAAO,CAACI,GAAxB,EAA6B,IAA7B;AACAF,IAAAA,GAAG,CAACG,YAAJ,GAAmB,aAAnB;AACAH,IAAAA,GAAG,CAACI,gBAAJ,CAAqB,MAArB,EAA6B,YAAW;AACtC,UAAIJ,GAAG,CAACK,MAAJ,GAAa,GAAjB,EAAsB;AACpB,YAAI;AACF,cAAMC,IAAI,GAAGC,MAAM,CAACC,IAAP,CAAY,KAAKC,QAAjB,CAAb;AACAV,UAAAA,EAAE,CAAC,IAAD,EAAOC,GAAP,EAAYM,IAAZ,CAAF;AACD,SAHD,CAGE,OAAOI,KAAP,EAAc;AACd,iBAAOX,EAAE,CACP,IAAIY,KAAJ,CACE,sCACEb,OAAO,CAACI,GADV,GAEE,WAFF,GAGEQ,KAAK,CAACE,OAJV,CADO,CAAT;AAQD;AACF,OAdD,MAcO;AACLb,QAAAA,EAAE,CAAC,IAAIY,KAAJ,CAAU,iBAAiBX,GAAG,CAACK,MAArB,GAA8B,WAA9B,GAA4CP,OAAO,CAACI,GAA9D,CAAD,CAAF;AACD;AACF,KAlBD;AAmBAF,IAAAA,GAAG,CAACI,gBAAJ,CAAqB,OAArB,EAA8B,UAAAS,CAAC,EAAI;AACjCd,MAAAA,EAAE,CAACc,CAAD,CAAF;AACD,KAFD;AAGAb,IAAAA,GAAG,CAACc,IAAJ;AACD,GA3BD;AA4BD,CAtCD,MAsCO;AACLlB,EAAAA,MAAM,CAACC,OAAP,GAAiB,gBAAyBE,EAAzB,EAA6B;AAAA,QAAfD,OAAe;;AAC5C,QAAMiB,CAAC,GAAGC,OAAO,CAAC,MAAD,CAAjB;;AAEAD,IAAAA,CAAC;AAAGE,MAAAA,WAAW,EAAE;AAAhB,OAAyBnB,OAAzB,GAAoC,UAACoB,GAAD,EAAMC,GAAN,EAAc;AACjD,UAAID,GAAG,KAAK,IAAZ,EAAkB;AAChBnB,QAAAA,EAAE,CAAC,IAAD,EAAOoB,GAAP,EAAYA,GAAG,CAACC,IAAhB,CAAF;AACD,OAFD,MAEO;AACLrB,QAAAA,EAAE,CAACmB,GAAD,CAAF;AACD;AACF,KANA,CAAD;AAOD,GAVD;AAWD","sourcesContent":["/* global XMLHttpRequest */\n\nif (\n process.browser ||\n process.env.ENVIRONMENT === 'BROWSER' ||\n (typeof process.versions.electron !== 'undefined' &&\n process.type === 'renderer' &&\n typeof XMLHttpRequest === 'function')\n) {\n // If we run into a browser or the electron renderer process,\n // use XHR method instead of Request node module.\n\n module.exports = function(options, cb) {\n const xhr = new XMLHttpRequest();\n xhr.open('GET', options.url, true);\n xhr.responseType = 'arraybuffer';\n xhr.addEventListener('load', function() {\n if (xhr.status < 400) {\n try {\n const data = Buffer.from(this.response);\n cb(null, xhr, data);\n } catch (error) {\n return cb(\n new Error(\n 'Response is not a buffer for url ' +\n options.url +\n '. Error: ' +\n error.message\n )\n );\n }\n } else {\n cb(new Error('HTTP Status ' + xhr.status + ' for url ' + options.url));\n }\n });\n xhr.addEventListener('error', e => {\n cb(e);\n });\n xhr.send();\n };\n} else {\n module.exports = function({ ...options }, cb) {\n const p = require('phin');\n\n p({ compression: true, ...options }, (err, res) => {\n if (err === null) {\n cb(null, res, res.body);\n } else {\n cb(err);\n }\n });\n };\n}\n"],"file":"request.js"}

163
node_modules/@jimp/core/es/utils/image-bitmap.js generated vendored Normal file
View File

@ -0,0 +1,163 @@
import fileType from 'file-type';
import EXIFParser from 'exif-parser';
import { throwError } from '@jimp/utils';
import * as constants from '../constants';
import * as MIME from './mime';
import promisify from './promisify';
function getMIMEFromBuffer(buffer, path) {
var fileTypeFromBuffer = fileType(buffer);
if (fileTypeFromBuffer) {
// If fileType returns something for buffer, then return the mime given
return fileTypeFromBuffer.mime;
}
if (path) {
// If a path is supplied, and fileType yields no results, then retry with MIME
// Path can be either a file path or a url
return MIME.getType(path);
}
return null;
}
/*
* Automagically rotates an image based on its EXIF data (if present)
* @param img a constants object
*/
function exifRotate(img) {
var exif = img._exif;
if (exif && exif.tags && exif.tags.Orientation) {
switch (img._exif.tags.Orientation) {
case 1:
// Horizontal (normal)
// do nothing
break;
case 2:
// Mirror horizontal
img.mirror(true, false);
break;
case 3:
// Rotate 180
img.rotate(180, false);
break;
case 4:
// Mirror vertical
img.mirror(false, true);
break;
case 5:
// Mirror horizontal and rotate 270 CW
img.rotate(-90, false).mirror(true, false);
break;
case 6:
// Rotate 90 CW
img.rotate(-90, false);
break;
case 7:
// Mirror horizontal and rotate 90 CW
img.rotate(90, false).mirror(true, false);
break;
case 8:
// Rotate 270 CW
img.rotate(-270, false);
break;
default:
break;
}
}
return img;
} // parses a bitmap from the constructor to the JIMP bitmap property
export function parseBitmap(data, path, cb) {
var mime = getMIMEFromBuffer(data, path);
if (typeof mime !== 'string') {
return cb(new Error('Could not find MIME for Buffer <' + path + '>'));
}
this._originalMime = mime.toLowerCase();
try {
var _mime = this.getMIME();
if (this.constructor.decoders[_mime]) {
this.bitmap = this.constructor.decoders[_mime](data);
} else {
return throwError.call(this, 'Unsupported MIME type: ' + _mime, cb);
}
} catch (error) {
return cb.call(this, error, this);
}
try {
this._exif = EXIFParser.create(data).parse();
exifRotate(this); // EXIF data
} catch (error) {
/* meh */
}
cb.call(this, null, this);
return this;
}
function compositeBitmapOverBackground(Jimp, image) {
return new Jimp(image.bitmap.width, image.bitmap.height, image._background).composite(image, 0, 0).bitmap;
}
/**
* Converts the image to a buffer
* @param {string} mime the mime type of the image buffer to be created
* @param {function(Error, Jimp)} cb a Node-style function to call with the buffer as the second argument
* @returns {Jimp} this for chaining of methods
*/
export function getBuffer(mime, cb) {
if (mime === constants.AUTO) {
// allow auto MIME detection
mime = this.getMIME();
}
if (typeof mime !== 'string') {
return throwError.call(this, 'mime must be a string', cb);
}
if (typeof cb !== 'function') {
return throwError.call(this, 'cb must be a function', cb);
}
mime = mime.toLowerCase();
if (this._rgba && this.constructor.hasAlpha[mime]) {
this.bitmap.data = Buffer.from(this.bitmap.data);
} else {
// when format doesn't support alpha
// composite onto a new image so that the background shows through alpha channels
this.bitmap.data = compositeBitmapOverBackground(this.constructor, this).data;
}
if (this.constructor.encoders[mime]) {
var buffer = this.constructor.encoders[mime](this);
cb.call(this, null, buffer);
} else {
cb.call(this, 'Unsupported MIME type: ' + mime);
}
return this;
}
export function getBufferAsync(mime) {
return promisify(getBuffer, this, mime);
}
//# sourceMappingURL=image-bitmap.js.map

1
node_modules/@jimp/core/es/utils/image-bitmap.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

33
node_modules/@jimp/core/es/utils/mime.js generated vendored Normal file
View File

@ -0,0 +1,33 @@
var mimeTypes = {};
var findType = function findType(extension) {
return Object.entries(mimeTypes).find(function (type) {
return type[1].includes(extension);
}) || [];
};
export var addType = function addType(mime, extensions) {
mimeTypes[mime] = extensions;
};
/**
* Lookup a mime type based on extension
* @param {string} path path to find extension for
* @returns {string} mime found mime type
*/
export var getType = function getType(path) {
var pathParts = path.split('/').slice(-1);
var extension = pathParts[pathParts.length - 1].split('.')[1];
var type = findType(extension);
return type[0];
};
/**
* Return file extension associated with a mime type
* @param {string} type mime type to look up
* @returns {string} extension file extension
*/
export var getExtension = function getExtension(type) {
return (mimeTypes[type.toLowerCase()] || [])[0];
};
//# sourceMappingURL=mime.js.map

1
node_modules/@jimp/core/es/utils/mime.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/mime.js"],"names":["mimeTypes","findType","extension","Object","entries","find","type","includes","addType","mime","extensions","getType","path","pathParts","split","slice","length","getExtension","toLowerCase"],"mappings":"AAAA,IAAMA,SAAS,GAAG,EAAlB;;AAEA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAAAC,SAAS;AAAA,SACxBC,MAAM,CAACC,OAAP,CAAeJ,SAAf,EAA0BK,IAA1B,CAA+B,UAAAC,IAAI;AAAA,WAAIA,IAAI,CAAC,CAAD,CAAJ,CAAQC,QAAR,CAAiBL,SAAjB,CAAJ;AAAA,GAAnC,KAAuE,EAD/C;AAAA,CAA1B;;AAGA,OAAO,IAAMM,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAOC,UAAP,EAAsB;AAC3CV,EAAAA,SAAS,CAACS,IAAD,CAAT,GAAkBC,UAAlB;AACD,CAFM;AAIP;;;;;;AAKA,OAAO,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAAAC,IAAI,EAAI;AAC7B,MAAMC,SAAS,GAAGD,IAAI,CAACE,KAAL,CAAW,GAAX,EAAgBC,KAAhB,CAAsB,CAAC,CAAvB,CAAlB;AACA,MAAMb,SAAS,GAAGW,SAAS,CAACA,SAAS,CAACG,MAAV,GAAmB,CAApB,CAAT,CAAgCF,KAAhC,CAAsC,GAAtC,EAA2C,CAA3C,CAAlB;AACA,MAAMR,IAAI,GAAGL,QAAQ,CAACC,SAAD,CAArB;AAEA,SAAOI,IAAI,CAAC,CAAD,CAAX;AACD,CANM;AAQP;;;;;;AAKA,OAAO,IAAMW,YAAY,GAAG,SAAfA,YAAe,CAAAX,IAAI;AAAA,SAAI,CAACN,SAAS,CAACM,IAAI,CAACY,WAAL,EAAD,CAAT,IAAiC,EAAlC,EAAsC,CAAtC,CAAJ;AAAA,CAAzB","sourcesContent":["const mimeTypes = {};\n\nconst findType = extension =>\n Object.entries(mimeTypes).find(type => type[1].includes(extension)) || [];\n\nexport const addType = (mime, extensions) => {\n mimeTypes[mime] = extensions;\n};\n\n/**\n * Lookup a mime type based on extension\n * @param {string} path path to find extension for\n * @returns {string} mime found mime type\n */\nexport const getType = path => {\n const pathParts = path.split('/').slice(-1);\n const extension = pathParts[pathParts.length - 1].split('.')[1];\n const type = findType(extension);\n\n return type[0];\n};\n\n/**\n * Return file extension associated with a mime type\n * @param {string} type mime type to look up\n * @returns {string} extension file extension\n */\nexport const getExtension = type => (mimeTypes[type.toLowerCase()] || [])[0];\n"],"file":"mime.js"}

19
node_modules/@jimp/core/es/utils/promisify.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
var promisify = function promisify(fun, ctx) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
return new Promise(function (resolve, reject) {
args.push(function (err, data) {
if (err) {
reject(err);
}
resolve(data);
});
fun.bind(ctx).apply(void 0, args);
});
};
export default promisify;
//# sourceMappingURL=promisify.js.map

1
node_modules/@jimp/core/es/utils/promisify.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/promisify.js"],"names":["promisify","fun","ctx","args","Promise","resolve","reject","push","err","data","bind"],"mappings":"AAAA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,GAAD,EAAMC,GAAN;AAAA,oCAAcC,IAAd;AAAcA,IAAAA,IAAd;AAAA;;AAAA,SAChB,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AAC/BH,IAAAA,IAAI,CAACI,IAAL,CAAU,UAACC,GAAD,EAAMC,IAAN,EAAe;AACvB,UAAID,GAAJ,EAAS;AACPF,QAAAA,MAAM,CAACE,GAAD,CAAN;AACD;;AAEDH,MAAAA,OAAO,CAACI,IAAD,CAAP;AACD,KAND;AAOAR,IAAAA,GAAG,CAACS,IAAJ,CAASR,GAAT,gBAAiBC,IAAjB;AACD,GATD,CADgB;AAAA,CAAlB;;AAYA,eAAeH,SAAf","sourcesContent":["const promisify = (fun, ctx, ...args) =>\n new Promise((resolve, reject) => {\n args.push((err, data) => {\n if (err) {\n reject(err);\n }\n\n resolve(data);\n });\n fun.bind(ctx)(...args);\n });\n\nexport default promisify;\n"],"file":"promisify.js"}