This commit is contained in:
54
node_modules/@jimp/core/CHANGELOG.md
generated
vendored
Normal file
54
node_modules/@jimp/core/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
# v0.10.2 (Tue Apr 14 2020)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- Rewrite handling EXIF orientation — add tests, make it plugin-independent [#875](https://github.com/oliver-moran/jimp/pull/875) ([@skalee](https://github.com/skalee))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Sebastian Skałacki ([@skalee](https://github.com/skalee))
|
||||
|
||||
---
|
||||
|
||||
# v0.10.0 (Mon Mar 30 2020)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- Properly split constructor and instance types [#867](https://github.com/oliver-moran/jimp/pull/867) ([@forivall](https://github.com/forivall))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Emily Marigold Klassen ([@forivall](https://github.com/forivall))
|
||||
|
||||
---
|
||||
|
||||
# v0.9.6 (Wed Mar 18 2020)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- Relax mkdirp dependency to allow newer minimist [#857](https://github.com/oliver-moran/jimp/pull/857) ([@Den-dp](https://github.com/Den-dp))
|
||||
|
||||
#### 🏠 Internal
|
||||
|
||||
- Fix TypeScript error on 'next' [#858](https://github.com/oliver-moran/jimp/pull/858) ([@crutchcorn](https://github.com/crutchcorn))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))
|
||||
- Denis Bendrikov ([@Den-dp](https://github.com/Den-dp))
|
||||
|
||||
---
|
||||
|
||||
# v0.9.3 (Tue Nov 26 2019)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- `@jimp/cli`, `@jimp/core`, `@jimp/custom`, `jimp`, `@jimp/plugin-blit`, `@jimp/plugin-blur`, `@jimp/plugin-circle`, `@jimp/plugin-color`, `@jimp/plugin-contain`, `@jimp/plugin-cover`, `@jimp/plugin-crop`, `@jimp/plugin-displace`, `@jimp/plugin-dither`, `@jimp/plugin-fisheye`, `@jimp/plugin-flip`, `@jimp/plugin-gaussian`, `@jimp/plugin-invert`, `@jimp/plugin-mask`, `@jimp/plugin-normalize`, `@jimp/plugin-print`, `@jimp/plugin-resize`, `@jimp/plugin-rotate`, `@jimp/plugin-scale`, `@jimp/plugin-shadow`, `@jimp/plugin-threshold`, `@jimp/plugins`, `@jimp/test-utils`, `@jimp/bmp`, `@jimp/gif`, `@jimp/jpeg`, `@jimp/png`, `@jimp/tiff`, `@jimp/types`, `@jimp/utils`
|
||||
- Fix regeneratorRuntime errors [#815](https://github.com/oliver-moran/jimp/pull/815) ([@crutchcorn](https://github.com/crutchcorn) [@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- `@jimp/core`
|
||||
- Follow redirects [#789](https://github.com/oliver-moran/jimp/pull/789) ([@SaWey](https://github.com/SaWey) sander@solora.be)
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))
|
||||
21
node_modules/@jimp/core/LICENSE
generated
vendored
Normal file
21
node_modules/@jimp/core/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Oliver Moran
|
||||
|
||||
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.
|
||||
52
node_modules/@jimp/core/README.md
generated
vendored
Normal file
52
node_modules/@jimp/core/README.md
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<div align="center">
|
||||
<img width="200" height="200"
|
||||
src="https://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-11/256/crayon.png">
|
||||
<h1>@jimp/core</h1>
|
||||
</div>
|
||||
|
||||
The main Jimp class. This class can be extended with types and bitmap manipulation functions. Out of the box it does not support any image type.
|
||||
|
||||
## Available Methods
|
||||
|
||||
### Jimp
|
||||
|
||||
The Jimp class constructor.
|
||||
|
||||
### addConstants
|
||||
|
||||
Add constant or static methods to the Jimp constructor.
|
||||
|
||||
```js
|
||||
addConstants({
|
||||
MIME_SPECIAL: 'image/special'
|
||||
});
|
||||
```
|
||||
|
||||
### addJimpMethods
|
||||
|
||||
Add a bitmap manipulation method to Jimp constructor. These method should return this so that the function can be chain-able.
|
||||
|
||||
```js
|
||||
addJimpMethods({
|
||||
cropCrazy: function() {
|
||||
// Your custom image manipulation method
|
||||
|
||||
return this;
|
||||
}
|
||||
})
|
||||
|
||||
const image = await Jimp.read(...);
|
||||
|
||||
image.resize(10, Jimp.AUTO),
|
||||
.cropCrazy();
|
||||
|
||||
await image.writeAsync('test.png');
|
||||
```
|
||||
|
||||
### addType
|
||||
|
||||
Add a image mime type to Jimp constructor. First argument is a mime type and the second is an array of file extension for that type.
|
||||
|
||||
```js
|
||||
addType('image/special', ['spec', 'special']);
|
||||
```
|
||||
214
node_modules/@jimp/core/es/composite/composite-modes.js
generated
vendored
Normal file
214
node_modules/@jimp/core/es/composite/composite-modes.js
generated
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.srcOver = srcOver;
|
||||
exports.dstOver = dstOver;
|
||||
exports.multiply = multiply;
|
||||
exports.screen = screen;
|
||||
exports.overlay = overlay;
|
||||
exports.darken = darken;
|
||||
exports.lighten = lighten;
|
||||
exports.hardLight = hardLight;
|
||||
exports.difference = difference;
|
||||
exports.exclusion = exclusion;
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
1
node_modules/@jimp/core/es/composite/composite-modes.js.map
generated
vendored
Normal file
1
node_modules/@jimp/core/es/composite/composite-modes.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
94
node_modules/@jimp/core/es/composite/index.js
generated
vendored
Normal file
94
node_modules/@jimp/core/es/composite/index.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = composite;
|
||||
|
||||
var _utils = require("@jimp/utils");
|
||||
|
||||
var constants = _interopRequireWildcard(require("../constants"));
|
||||
|
||||
var compositeModes = _interopRequireWildcard(require("./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
|
||||
*/
|
||||
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 _utils.throwError.call(this, 'The source must be a Jimp image', cb);
|
||||
}
|
||||
|
||||
if (typeof x !== 'number' || typeof y !== 'number') {
|
||||
return _utils.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 ((0, _utils.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
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
51
node_modules/@jimp/core/es/constants.js
generated
vendored
Normal file
51
node_modules/@jimp/core/es/constants.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.EDGE_CROP = exports.EDGE_WRAP = exports.EDGE_EXTEND = exports.BLEND_EXCLUSION = exports.BLEND_DIFFERENCE = exports.BLEND_HARDLIGHT = exports.BLEND_LIGHTEN = exports.BLEND_DARKEN = exports.BLEND_OVERLAY = exports.BLEND_SCREEN = exports.BLEND_MULTIPLY = exports.BLEND_DESTINATION_OVER = exports.BLEND_SOURCE_OVER = exports.VERTICAL_ALIGN_BOTTOM = exports.VERTICAL_ALIGN_MIDDLE = exports.VERTICAL_ALIGN_TOP = exports.HORIZONTAL_ALIGN_RIGHT = exports.HORIZONTAL_ALIGN_CENTER = exports.HORIZONTAL_ALIGN_LEFT = exports.AUTO = void 0;
|
||||
// used to auto resizing etc.
|
||||
var AUTO = -1; // Align modes for cover, contain, bit masks
|
||||
|
||||
exports.AUTO = AUTO;
|
||||
var HORIZONTAL_ALIGN_LEFT = 1;
|
||||
exports.HORIZONTAL_ALIGN_LEFT = HORIZONTAL_ALIGN_LEFT;
|
||||
var HORIZONTAL_ALIGN_CENTER = 2;
|
||||
exports.HORIZONTAL_ALIGN_CENTER = HORIZONTAL_ALIGN_CENTER;
|
||||
var HORIZONTAL_ALIGN_RIGHT = 4;
|
||||
exports.HORIZONTAL_ALIGN_RIGHT = HORIZONTAL_ALIGN_RIGHT;
|
||||
var VERTICAL_ALIGN_TOP = 8;
|
||||
exports.VERTICAL_ALIGN_TOP = VERTICAL_ALIGN_TOP;
|
||||
var VERTICAL_ALIGN_MIDDLE = 16;
|
||||
exports.VERTICAL_ALIGN_MIDDLE = VERTICAL_ALIGN_MIDDLE;
|
||||
var VERTICAL_ALIGN_BOTTOM = 32; // blend modes
|
||||
|
||||
exports.VERTICAL_ALIGN_BOTTOM = VERTICAL_ALIGN_BOTTOM;
|
||||
var BLEND_SOURCE_OVER = 'srcOver';
|
||||
exports.BLEND_SOURCE_OVER = BLEND_SOURCE_OVER;
|
||||
var BLEND_DESTINATION_OVER = 'dstOver';
|
||||
exports.BLEND_DESTINATION_OVER = BLEND_DESTINATION_OVER;
|
||||
var BLEND_MULTIPLY = 'multiply';
|
||||
exports.BLEND_MULTIPLY = BLEND_MULTIPLY;
|
||||
var BLEND_SCREEN = 'screen';
|
||||
exports.BLEND_SCREEN = BLEND_SCREEN;
|
||||
var BLEND_OVERLAY = 'overlay';
|
||||
exports.BLEND_OVERLAY = BLEND_OVERLAY;
|
||||
var BLEND_DARKEN = 'darken';
|
||||
exports.BLEND_DARKEN = BLEND_DARKEN;
|
||||
var BLEND_LIGHTEN = 'lighten';
|
||||
exports.BLEND_LIGHTEN = BLEND_LIGHTEN;
|
||||
var BLEND_HARDLIGHT = 'hardLight';
|
||||
exports.BLEND_HARDLIGHT = BLEND_HARDLIGHT;
|
||||
var BLEND_DIFFERENCE = 'difference';
|
||||
exports.BLEND_DIFFERENCE = BLEND_DIFFERENCE;
|
||||
var BLEND_EXCLUSION = 'exclusion'; // Edge Handling
|
||||
|
||||
exports.BLEND_EXCLUSION = BLEND_EXCLUSION;
|
||||
var EDGE_EXTEND = 1;
|
||||
exports.EDGE_EXTEND = EDGE_EXTEND;
|
||||
var EDGE_WRAP = 2;
|
||||
exports.EDGE_WRAP = EDGE_WRAP;
|
||||
var EDGE_CROP = 3;
|
||||
exports.EDGE_CROP = EDGE_CROP;
|
||||
//# sourceMappingURL=constants.js.map
|
||||
1
node_modules/@jimp/core/es/constants.js.map
generated
vendored
Normal file
1
node_modules/@jimp/core/es/constants.js.map
generated
vendored
Normal 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;AACO,IAAMA,IAAI,GAAG,CAAC,CAAd,C,CAEP;;;AACO,IAAMC,qBAAqB,GAAG,CAA9B;;AACA,IAAMC,uBAAuB,GAAG,CAAhC;;AACA,IAAMC,sBAAsB,GAAG,CAA/B;;AAEA,IAAMC,kBAAkB,GAAG,CAA3B;;AACA,IAAMC,qBAAqB,GAAG,EAA9B;;AACA,IAAMC,qBAAqB,GAAG,EAA9B,C,CAEP;;;AACO,IAAMC,iBAAiB,GAAG,SAA1B;;AACA,IAAMC,sBAAsB,GAAG,SAA/B;;AACA,IAAMC,cAAc,GAAG,UAAvB;;AACA,IAAMC,YAAY,GAAG,QAArB;;AACA,IAAMC,aAAa,GAAG,SAAtB;;AACA,IAAMC,YAAY,GAAG,QAArB;;AACA,IAAMC,aAAa,GAAG,SAAtB;;AACA,IAAMC,eAAe,GAAG,WAAxB;;AACA,IAAMC,gBAAgB,GAAG,YAAzB;;AACA,IAAMC,eAAe,GAAG,WAAxB,C,CAEP;;;AACO,IAAMC,WAAW,GAAG,CAApB;;AACA,IAAMC,SAAS,GAAG,CAAlB;;AACA,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"}
|
||||
1291
node_modules/@jimp/core/es/index.js
generated
vendored
Executable file
1291
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
1
node_modules/@jimp/core/es/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
173
node_modules/@jimp/core/es/modules/phash.js
generated
vendored
Normal file
173
node_modules/@jimp/core/es/modules/phash.js
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
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
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
55
node_modules/@jimp/core/es/request.js
generated
vendored
Normal file
55
node_modules/@jimp/core/es/request.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
||||
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
/* 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 = (0, _extends2["default"])({}, _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
1
node_modules/@jimp/core/es/request.js.map
generated
vendored
Normal 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"}
|
||||
263
node_modules/@jimp/core/es/utils/image-bitmap.js
generated
vendored
Normal file
263
node_modules/@jimp/core/es/utils/image-bitmap.js
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.parseBitmap = parseBitmap;
|
||||
exports.getBuffer = getBuffer;
|
||||
exports.getBufferAsync = getBufferAsync;
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _fileType = _interopRequireDefault(require("file-type"));
|
||||
|
||||
var _exifParser = _interopRequireDefault(require("exif-parser"));
|
||||
|
||||
var _utils = require("@jimp/utils");
|
||||
|
||||
var constants = _interopRequireWildcard(require("../constants"));
|
||||
|
||||
var MIME = _interopRequireWildcard(require("./mime"));
|
||||
|
||||
var _promisify = _interopRequireDefault(require("./promisify"));
|
||||
|
||||
function getMIMEFromBuffer(buffer, path) {
|
||||
var fileTypeFromBuffer = (0, _fileType["default"])(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;
|
||||
}
|
||||
/*
|
||||
* Obtains image orientation from EXIF metadata.
|
||||
*
|
||||
* @param img {Jimp} a Jimp image object
|
||||
* @returns {number} a number 1-8 representing EXIF orientation,
|
||||
* in particular 1 if orientation tag is missing
|
||||
*/
|
||||
|
||||
|
||||
function getExifOrientation(img) {
|
||||
return img._exif && img._exif.tags && img._exif.tags.Orientation || 1;
|
||||
}
|
||||
/**
|
||||
* Returns a function which translates EXIF-rotated coordinates into
|
||||
* non-rotated ones.
|
||||
*
|
||||
* Transformation reference: http://sylvana.net/jpegcrop/exif_orientation.html.
|
||||
*
|
||||
* @param img {Jimp} a Jimp image object
|
||||
* @returns {function} transformation function for transformBitmap().
|
||||
*/
|
||||
|
||||
|
||||
function getExifOrientationTransformation(img) {
|
||||
var w = img.getWidth();
|
||||
var h = img.getHeight();
|
||||
|
||||
switch (getExifOrientation(img)) {
|
||||
case 1:
|
||||
// Horizontal (normal)
|
||||
// does not need to be supported here
|
||||
return null;
|
||||
|
||||
case 2:
|
||||
// Mirror horizontal
|
||||
return function (x, y) {
|
||||
return [w - x - 1, y];
|
||||
};
|
||||
|
||||
case 3:
|
||||
// Rotate 180
|
||||
return function (x, y) {
|
||||
return [w - x - 1, h - y - 1];
|
||||
};
|
||||
|
||||
case 4:
|
||||
// Mirror vertical
|
||||
return function (x, y) {
|
||||
return [x, h - y - 1];
|
||||
};
|
||||
|
||||
case 5:
|
||||
// Mirror horizontal and rotate 270 CW
|
||||
return function (x, y) {
|
||||
return [y, x];
|
||||
};
|
||||
|
||||
case 6:
|
||||
// Rotate 90 CW
|
||||
return function (x, y) {
|
||||
return [y, h - x - 1];
|
||||
};
|
||||
|
||||
case 7:
|
||||
// Mirror horizontal and rotate 90 CW
|
||||
return function (x, y) {
|
||||
return [w - y - 1, h - x - 1];
|
||||
};
|
||||
|
||||
case 8:
|
||||
// Rotate 270 CW
|
||||
return function (x, y) {
|
||||
return [w - y - 1, x];
|
||||
};
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Transforms bitmap in place (moves pixels around) according to given
|
||||
* transformation function.
|
||||
*
|
||||
* @param img {Jimp} a Jimp image object, which bitmap is supposed to
|
||||
* be transformed
|
||||
* @param width {number} bitmap width after the transformation
|
||||
* @param height {number} bitmap height after the transformation
|
||||
* @param transformation {function} transformation function which defines pixel
|
||||
* mapping between new and source bitmap. It takes a pair of coordinates
|
||||
* in the target, and returns a respective pair of coordinates in
|
||||
* the source bitmap, i.e. has following form:
|
||||
* `function(new_x, new_y) { return [src_x, src_y] }`.
|
||||
*/
|
||||
|
||||
|
||||
function transformBitmap(img, width, height, transformation) {
|
||||
// Underscore-prefixed values are related to the source bitmap
|
||||
// Their counterparts with no prefix are related to the target bitmap
|
||||
var _data = img.bitmap.data;
|
||||
var _width = img.bitmap.width;
|
||||
var data = Buffer.alloc(_data.length);
|
||||
|
||||
for (var x = 0; x < width; x++) {
|
||||
for (var y = 0; y < height; y++) {
|
||||
var _transformation = transformation(x, y),
|
||||
_transformation2 = (0, _slicedToArray2["default"])(_transformation, 2),
|
||||
_x = _transformation2[0],
|
||||
_y = _transformation2[1];
|
||||
|
||||
var idx = width * y + x << 2;
|
||||
|
||||
var _idx = _width * _y + _x << 2;
|
||||
|
||||
var pixel = _data.readUInt32BE(_idx);
|
||||
|
||||
data.writeUInt32BE(pixel, idx);
|
||||
}
|
||||
}
|
||||
|
||||
img.bitmap.data = data;
|
||||
img.bitmap.width = width;
|
||||
img.bitmap.height = height;
|
||||
}
|
||||
/*
|
||||
* Automagically rotates an image based on its EXIF data (if present).
|
||||
* @param img {Jimp} a Jimp image object
|
||||
*/
|
||||
|
||||
|
||||
function exifRotate(img) {
|
||||
if (getExifOrientation(img) < 2) return;
|
||||
var transformation = getExifOrientationTransformation(img);
|
||||
var swapDimensions = getExifOrientation(img) > 4;
|
||||
var newWidth = swapDimensions ? img.bitmap.height : img.bitmap.width;
|
||||
var newHeight = swapDimensions ? img.bitmap.width : img.bitmap.height;
|
||||
transformBitmap(img, newWidth, newHeight, transformation);
|
||||
} // parses a bitmap from the constructor to the JIMP bitmap property
|
||||
|
||||
|
||||
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 _utils.throwError.call(this, 'Unsupported MIME type: ' + _mime, cb);
|
||||
}
|
||||
} catch (error) {
|
||||
return cb.call(this, error, this);
|
||||
}
|
||||
|
||||
try {
|
||||
this._exif = _exifParser["default"].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
|
||||
*/
|
||||
|
||||
|
||||
function getBuffer(mime, cb) {
|
||||
if (mime === constants.AUTO) {
|
||||
// allow auto MIME detection
|
||||
mime = this.getMIME();
|
||||
}
|
||||
|
||||
if (typeof mime !== 'string') {
|
||||
return _utils.throwError.call(this, 'mime must be a string', cb);
|
||||
}
|
||||
|
||||
if (typeof cb !== 'function') {
|
||||
return _utils.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;
|
||||
}
|
||||
|
||||
function getBufferAsync(mime) {
|
||||
return (0, _promisify["default"])(getBuffer, this, mime);
|
||||
}
|
||||
//# sourceMappingURL=image-bitmap.js.map
|
||||
1
node_modules/@jimp/core/es/utils/image-bitmap.js.map
generated
vendored
Normal file
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
47
node_modules/@jimp/core/es/utils/mime.js
generated
vendored
Normal file
47
node_modules/@jimp/core/es/utils/mime.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getExtension = exports.getType = exports.addType = void 0;
|
||||
var mimeTypes = {};
|
||||
|
||||
var findType = function findType(extension) {
|
||||
return Object.entries(mimeTypes).find(function (type) {
|
||||
return type[1].includes(extension);
|
||||
}) || [];
|
||||
};
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
|
||||
exports.addType = addType;
|
||||
|
||||
var getType = function getType(path) {
|
||||
var pathParts = path.split('/').slice(-1);
|
||||
var extension = pathParts[pathParts.length - 1].split('.').pop();
|
||||
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
|
||||
*/
|
||||
|
||||
|
||||
exports.getType = getType;
|
||||
|
||||
var getExtension = function getExtension(type) {
|
||||
return (mimeTypes[type.toLowerCase()] || [])[0];
|
||||
};
|
||||
|
||||
exports.getExtension = getExtension;
|
||||
//# sourceMappingURL=mime.js.map
|
||||
1
node_modules/@jimp/core/es/utils/mime.js.map
generated
vendored
Normal file
1
node_modules/@jimp/core/es/utils/mime.js.map
generated
vendored
Normal 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","pop","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;;AAGO,IAAMM,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAOC,UAAP,EAAsB;AAC3CV,EAAAA,SAAS,CAACS,IAAD,CAAT,GAAkBC,UAAlB;AACD,CAFM;AAIP;;;;;;;;;AAKO,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,EAA2CG,GAA3C,EAAlB;AACA,MAAMX,IAAI,GAAGL,QAAQ,CAACC,SAAD,CAArB;AAEA,SAAOI,IAAI,CAAC,CAAD,CAAX;AACD,CANM;AAQP;;;;;;;;;AAKO,IAAMY,YAAY,GAAG,SAAfA,YAAe,CAAAZ,IAAI;AAAA,SAAI,CAACN,SAAS,CAACM,IAAI,CAACa,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('.').pop();\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"}
|
||||
27
node_modules/@jimp/core/es/utils/promisify.js
generated
vendored
Normal file
27
node_modules/@jimp/core/es/utils/promisify.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = void 0;
|
||||
|
||||
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);
|
||||
});
|
||||
};
|
||||
|
||||
var _default = promisify;
|
||||
exports["default"] = _default;
|
||||
//# sourceMappingURL=promisify.js.map
|
||||
1
node_modules/@jimp/core/es/utils/promisify.js.map
generated
vendored
Normal file
1
node_modules/@jimp/core/es/utils/promisify.js.map
generated
vendored
Normal 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;;eAYeH,S","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"}
|
||||
58
node_modules/@jimp/core/package.json
generated
vendored
Normal file
58
node_modules/@jimp/core/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "@jimp/core",
|
||||
"version": "0.10.3",
|
||||
"description": "Jimp core",
|
||||
"main": "dist/index.js",
|
||||
"module": "es/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"es",
|
||||
"index.d.ts",
|
||||
"fonts",
|
||||
"types"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/oliver-moran/jimp.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/oliver-moran/jimp/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "cross-env BABEL_ENV=test mocha --require @babel/register test/**/*.js",
|
||||
"test:watch": "npm run test -- --reporter min --watch",
|
||||
"test:coverage": "nyc npm run test",
|
||||
"build": "npm run build:node:production && npm run build:module",
|
||||
"build:watch": "npm run build:node:debug -- -- --watch --verbose",
|
||||
"build:debug": "npm run build:node:debug",
|
||||
"build:module": "cross-env BABEL_ENV=module babel src -d es --source-maps --config-file ../../babel.config.js",
|
||||
"build:node": "babel src -d dist --source-maps --config-file ../../babel.config.js",
|
||||
"build:node:debug": "cross-env BABEL_ENV=development npm run build:node",
|
||||
"build:node:production": "cross-env BABEL_ENV=production npm run build:node"
|
||||
},
|
||||
"author": "Oliver Moran <oliver.moran@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.7.2",
|
||||
"@jimp/utils": "^0.10.3",
|
||||
"any-base": "^1.1.0",
|
||||
"buffer": "^5.2.0",
|
||||
"core-js": "^3.4.1",
|
||||
"exif-parser": "^0.1.12",
|
||||
"file-type": "^9.0.0",
|
||||
"load-bmfont": "^1.3.1",
|
||||
"mkdirp": "^0.5.1",
|
||||
"phin": "^2.9.1",
|
||||
"pixelmatch": "^4.0.2",
|
||||
"tinycolor2": "^1.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"should": "^13.2.3"
|
||||
},
|
||||
"xo": false,
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "37197106eae5c26231018dfdc0254422f6b43927"
|
||||
}
|
||||
91
node_modules/@jimp/core/types/etc.d.ts
generated
vendored
Normal file
91
node_modules/@jimp/core/types/etc.d.ts
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
import {Jimp} from './jimp';
|
||||
|
||||
export interface Image {
|
||||
bitmap: Bitmap;
|
||||
}
|
||||
|
||||
export type DecoderFn = (data: Buffer) => Bitmap;
|
||||
export type EncoderFn<ImageType extends Image = Image> = (
|
||||
image: ImageType
|
||||
) => Buffer;
|
||||
|
||||
export type GenericCallback<T, U = any, TThis = any> = (
|
||||
this: TThis,
|
||||
err: Error | null,
|
||||
value: T
|
||||
) => U;
|
||||
|
||||
/**
|
||||
* `jimp` must be defined otherwise `this` will not apply properly
|
||||
* for custom configurations where plugins and types are needed
|
||||
*/
|
||||
export type ImageCallback<jimp = Jimp> = (
|
||||
this: jimp,
|
||||
err: Error | null,
|
||||
value: jimp,
|
||||
coords: {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
) => any;
|
||||
|
||||
type BlendMode = {
|
||||
mode: string;
|
||||
opacitySource: number;
|
||||
opacityDest: number;
|
||||
};
|
||||
|
||||
type ChangeName = 'background' | 'scan' | 'crop';
|
||||
|
||||
type ListenableName =
|
||||
| 'any'
|
||||
| 'initialized'
|
||||
| 'before-change'
|
||||
| 'changed'
|
||||
| 'before-clone'
|
||||
| 'cloned'
|
||||
| ChangeName;
|
||||
|
||||
type ListenerData<T extends ListenableName> = T extends 'any'
|
||||
? any
|
||||
: T extends ChangeName
|
||||
? {
|
||||
eventName: 'before-change' | 'changed';
|
||||
methodName: T;
|
||||
[key: string]: any;
|
||||
}
|
||||
: {
|
||||
eventName: T;
|
||||
methodName: T extends 'initialized'
|
||||
? 'constructor'
|
||||
: T extends 'before-change' | 'changed'
|
||||
? ChangeName
|
||||
: T extends 'before-clone' | 'cloned' ? 'clone' : any;
|
||||
};
|
||||
|
||||
type URLOptions = {
|
||||
url: string;
|
||||
compression?: boolean;
|
||||
headers: {
|
||||
[key: string]: any;
|
||||
};
|
||||
};
|
||||
|
||||
export interface Bitmap {
|
||||
data: Buffer;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
export interface RGB {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
}
|
||||
|
||||
export interface RGBA {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
a: number;
|
||||
}
|
||||
17
node_modules/@jimp/core/types/functions.d.ts
generated
vendored
Normal file
17
node_modules/@jimp/core/types/functions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import {Jimp} from './jimp';
|
||||
|
||||
export function addConstants(
|
||||
constants: [string, string | number],
|
||||
jimpInstance?: Jimp
|
||||
): void;
|
||||
export function addJimpMethods(
|
||||
methods: [string, Function],
|
||||
jimpInstance?: Jimp
|
||||
): void;
|
||||
export function jimpEvMethod(
|
||||
methodName: string,
|
||||
evName: string,
|
||||
method: Function
|
||||
): void;
|
||||
export function jimpEvChange(methodName: string, method: Function): void;
|
||||
export function addType(mime: string, extensions: string[]): void;
|
||||
9
node_modules/@jimp/core/types/index.d.ts
generated
vendored
Normal file
9
node_modules/@jimp/core/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export * from './etc';
|
||||
export * from './functions';
|
||||
export * from './plugins';
|
||||
export * from './utils';
|
||||
import {Jimp, JimpConstructors} from './jimp';
|
||||
|
||||
export { Jimp, JimpConstructors };
|
||||
declare const defaultExp: Jimp;
|
||||
export default defaultExp;
|
||||
218
node_modules/@jimp/core/types/jimp.d.ts
generated
vendored
Normal file
218
node_modules/@jimp/core/types/jimp.d.ts
generated
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
import {
|
||||
Bitmap,
|
||||
ImageCallback,
|
||||
URLOptions,
|
||||
ListenableName,
|
||||
ListenerData,
|
||||
GenericCallback,
|
||||
BlendMode,
|
||||
RGBA,
|
||||
RGB
|
||||
} from './etc';
|
||||
|
||||
interface DiffReturn<This> {
|
||||
percent: number;
|
||||
image: This;
|
||||
}
|
||||
|
||||
interface ScanIteratorReturn<This> {
|
||||
x: number;
|
||||
y: number;
|
||||
idx: number;
|
||||
image: This;
|
||||
}
|
||||
|
||||
export interface JimpConstructors {
|
||||
prototype: Jimp;
|
||||
// Constants
|
||||
AUTO: -1;
|
||||
// blend modes
|
||||
BLEND_SOURCE_OVER: string;
|
||||
BLEND_DESTINATION_OVER: string;
|
||||
BLEND_MULTIPLY: string;
|
||||
BLEND_SCREEN: string;
|
||||
BLEND_OVERLAY: string;
|
||||
BLEND_DARKEN: string;
|
||||
BLEND_LIGHTEN: string;
|
||||
BLEND_HARDLIGHT: string;
|
||||
BLEND_DIFFERENCE: string;
|
||||
BLEND_EXCLUSION: string;
|
||||
// Align modes for cover, contain, bit masks
|
||||
HORIZONTAL_ALIGN_LEFT: 1;
|
||||
HORIZONTAL_ALIGN_CENTER: 2;
|
||||
HORIZONTAL_ALIGN_RIGHT: 4;
|
||||
VERTICAL_ALIGN_TOP: 8;
|
||||
VERTICAL_ALIGN_MIDDLE: 16;
|
||||
VERTICAL_ALIGN_BOTTOM: 32;
|
||||
// Edge Handling
|
||||
EDGE_EXTEND: 1;
|
||||
EDGE_WRAP: 2;
|
||||
EDGE_CROP: 3;
|
||||
|
||||
// Constructors
|
||||
new(path: string, cb?: ImageCallback<this['prototype']>): this['prototype'];
|
||||
new(urlOptions: URLOptions, cb?: ImageCallback<this['prototype']>): this['prototype'];
|
||||
new(image: Jimp, cb?: ImageCallback<this['prototype']>): this['prototype'];
|
||||
new(data: Buffer, cb?: ImageCallback<this['prototype']>): this['prototype'];
|
||||
new(data: Bitmap, cb?: ImageCallback<this['prototype']>): this['prototype'];
|
||||
new(w: number, h: number, cb?: ImageCallback<this['prototype']>): this['prototype'];
|
||||
new(
|
||||
w: number,
|
||||
h: number,
|
||||
background?: number | string,
|
||||
cb?: ImageCallback<this['prototype']>
|
||||
): this['prototype'];
|
||||
// For custom constructors when using Jimp.appendConstructorOption
|
||||
new(...args: any[]): this['prototype'];
|
||||
|
||||
// Functions
|
||||
/**
|
||||
* I'd like to make `Args` generic and used in `run` and `test` but alas,
|
||||
* it's not possible RN:
|
||||
* https://github.com/microsoft/TypeScript/issues/26113
|
||||
*/
|
||||
appendConstructorOption<Args extends any[], J extends Jimp = this['prototype']>(
|
||||
name: string,
|
||||
test: (...args: any[]) => boolean,
|
||||
run: (
|
||||
this: J,
|
||||
resolve: (jimp?: J) => any,
|
||||
reject: (reason: Error) => any,
|
||||
...args: any[]
|
||||
) => any
|
||||
): void;
|
||||
read(path: string, cb?: ImageCallback<this['prototype']>): Promise<this['prototype']>;
|
||||
read(image: Jimp, cb?: ImageCallback<this['prototype']>): Promise<this['prototype']>;
|
||||
read(data: Buffer, cb?: ImageCallback<this['prototype']>): Promise<this['prototype']>;
|
||||
read(
|
||||
w: number,
|
||||
h: number,
|
||||
background?: number | string,
|
||||
cb?: ImageCallback<this['prototype']>
|
||||
): Promise<this['prototype']>;
|
||||
create(path: string): Promise<this['prototype']>;
|
||||
create(image: Jimp): Promise<this['prototype']>;
|
||||
create(data: Buffer): Promise<this['prototype']>;
|
||||
create(w: number, h: number, background?: number | string): Promise<this['prototype']>;
|
||||
rgbaToInt(
|
||||
r: number,
|
||||
g: number,
|
||||
b: number,
|
||||
a: number,
|
||||
cb: GenericCallback<number, any, this['prototype']>
|
||||
): number;
|
||||
intToRGBA(i: number, cb?: GenericCallback<RGBA>): RGBA;
|
||||
cssColorToHex(cssColor: string): number;
|
||||
limit255(n: number): number;
|
||||
diff(img1: Jimp, img2: Jimp, threshold?: number): DiffReturn<this['prototype']>;
|
||||
distance(img1: Jimp, img2: Jimp): number;
|
||||
compareHashes(hash1: string, hash2: string): number;
|
||||
colorDiff(rgba1: RGB, rgba2: RGB): number;
|
||||
colorDiff(rgba1: RGBA, rgba2: RGBA): number;
|
||||
}
|
||||
|
||||
export interface Jimp {
|
||||
// Properties
|
||||
bitmap: Bitmap;
|
||||
_rgba: boolean;
|
||||
_background: number;
|
||||
_originalMime: string;
|
||||
// Methods
|
||||
on<T extends ListenableName>(
|
||||
event: T,
|
||||
cb: (data: ListenerData<T>) => any
|
||||
): any;
|
||||
parseBitmap(
|
||||
data: Buffer,
|
||||
path: string | null | undefined,
|
||||
cb?: ImageCallback<this>
|
||||
): void;
|
||||
hasAlpha(): boolean;
|
||||
getHeight(): number;
|
||||
getWidth(): number;
|
||||
inspect(): string;
|
||||
toString(): string;
|
||||
getMIME(): string;
|
||||
getExtension(): string;
|
||||
distanceFromHash(hash: string): number;
|
||||
write(path: string, cb?: ImageCallback<this>): this;
|
||||
writeAsync(path: string): Promise<this>;
|
||||
rgba(bool: boolean, cb?: ImageCallback<this>): this;
|
||||
getBase64(mime: string, cb: GenericCallback<string, any, this>): this;
|
||||
getBase64Async(mime: string): Promise<string>;
|
||||
hash(cb?: GenericCallback<string, any, this>): string;
|
||||
hash(
|
||||
base: number | null | undefined,
|
||||
cb?: GenericCallback<string, any, this>
|
||||
): string;
|
||||
getBuffer(mime: string, cb: GenericCallback<Buffer>): this;
|
||||
getBufferAsync(mime: string): Promise<Buffer>;
|
||||
getPixelIndex(
|
||||
x: number,
|
||||
y: number,
|
||||
cb?: GenericCallback<number, any, this>
|
||||
): number;
|
||||
getPixelIndex(
|
||||
x: number,
|
||||
y: number,
|
||||
edgeHandling: string,
|
||||
cb?: GenericCallback<number, any, this>
|
||||
): number;
|
||||
getPixelColor(
|
||||
x: number,
|
||||
y: number,
|
||||
cb?: GenericCallback<number, any, this>
|
||||
): number;
|
||||
getPixelColour(
|
||||
x: number,
|
||||
y: number,
|
||||
cb?: GenericCallback<number, any, this>
|
||||
): number;
|
||||
setPixelColor(
|
||||
hex: number,
|
||||
x: number,
|
||||
y: number,
|
||||
cb?: ImageCallback<this>
|
||||
): this;
|
||||
setPixelColour(
|
||||
hex: number,
|
||||
x: number,
|
||||
y: number,
|
||||
cb?: ImageCallback<this>
|
||||
): this;
|
||||
clone(cb?: ImageCallback<this>): this;
|
||||
cloneQuiet(cb?: ImageCallback<this>): this;
|
||||
background(hex: number, cb?: ImageCallback<this>): this;
|
||||
backgroundQuiet(hex: number, cb?: ImageCallback<this>): this;
|
||||
scan(
|
||||
x: number,
|
||||
y: number,
|
||||
w: number,
|
||||
h: number,
|
||||
f: (this: this, x: number, y: number, idx: number) => any,
|
||||
cb?: ImageCallback<this>
|
||||
): this;
|
||||
scanQuiet(
|
||||
x: number,
|
||||
y: number,
|
||||
w: number,
|
||||
h: number,
|
||||
f: (this: this, x: number, y: number, idx: number) => any,
|
||||
cb?: ImageCallback<this>
|
||||
): this;
|
||||
scanIterator(
|
||||
x: number,
|
||||
y: number,
|
||||
w: number,
|
||||
h: number
|
||||
): IterableIterator<ScanIteratorReturn<this>>;
|
||||
|
||||
// Effect methods
|
||||
composite(
|
||||
src: Jimp,
|
||||
x: number,
|
||||
y: number,
|
||||
options?: BlendMode,
|
||||
cb?: ImageCallback<this>
|
||||
): this;
|
||||
}
|
||||
57
node_modules/@jimp/core/types/plugins.d.ts
generated
vendored
Normal file
57
node_modules/@jimp/core/types/plugins.d.ts
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* These files pertain to the typings of plugins or types
|
||||
*
|
||||
* They're not meant as utils to decode types, but rather
|
||||
* the type definitons themsleves for plugins and types of various kinds
|
||||
*/
|
||||
import {
|
||||
Image,
|
||||
EncoderFn,
|
||||
DecoderFn
|
||||
} from './etc';
|
||||
|
||||
import {
|
||||
Omit
|
||||
} from './utils';
|
||||
|
||||
export type IllformedPlugin = Omit<any, 'class' | 'constants'> & {
|
||||
class?: never;
|
||||
constants?: never;
|
||||
}
|
||||
|
||||
export interface WellFormedPlugin<ImageType extends Image = Image> {
|
||||
mime?: {
|
||||
[MIME_TYPE: string]: string[];
|
||||
};
|
||||
hasAlpha?: {
|
||||
[MIME_SPECIAL: string]: boolean;
|
||||
};
|
||||
constants?: {
|
||||
// Contants to assign to the Jimp instance
|
||||
[MIME_SPECIAL: string]: any;
|
||||
};
|
||||
decoders?: {
|
||||
[MIME_TYPE: string]: DecoderFn;
|
||||
};
|
||||
encoders?: {
|
||||
// Jimp Image
|
||||
[MIME_TYPE: string]: EncoderFn<ImageType>;
|
||||
};
|
||||
// Extend the Jimp class with the following constants, etc
|
||||
class?: any;
|
||||
}
|
||||
|
||||
type ClassOrConstantPlugin<T extends Image> = WellFormedPlugin<T> &
|
||||
(
|
||||
| Required<Pick<WellFormedPlugin<T>, 'class'>>
|
||||
| Required<Pick<WellFormedPlugin<T>, 'constants'>>
|
||||
);
|
||||
|
||||
// A Jimp type requires mime, but not class
|
||||
export type JimpType<T extends Image = Image> = WellFormedPlugin<T> &
|
||||
Required<Pick<WellFormedPlugin<T>, 'mime'>>;
|
||||
|
||||
// Jimp plugin either MUST have class OR constant or be illformed
|
||||
export type JimpPlugin<T extends Image = Image> =
|
||||
| ClassOrConstantPlugin<T>
|
||||
| IllformedPlugin;
|
||||
104
node_modules/@jimp/core/types/utils.d.ts
generated
vendored
Normal file
104
node_modules/@jimp/core/types/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
import {
|
||||
JimpType,
|
||||
JimpPlugin,
|
||||
} from './plugins';
|
||||
|
||||
// This is required as providing type arrays gives a union of all the generic
|
||||
// types in the array rather than an intersection
|
||||
export type UnionToIntersection<U> =
|
||||
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
||||
|
||||
/**
|
||||
* The values to be extracted from a WellFormedPlugin to put onto the Jimp instance
|
||||
* Left loose as "any" in order to enable the GetPluginVal to work properly
|
||||
*/
|
||||
export type WellFormedValues<T extends any> =
|
||||
(T extends {class: infer Class} ? Class : {});
|
||||
|
||||
/**
|
||||
* The constants to be extracted from a WellFormedPlugin to put onto the Jimp instance
|
||||
* Left loose as "any" in order to enable the GetPluginConstants to work properly
|
||||
*/
|
||||
export type WellFormedConstants<T extends any> =
|
||||
(T extends {constants: infer Constants} ? Constants : {});
|
||||
|
||||
// Util type for the functions that deal with `@jimp/custom`
|
||||
// Must accept any or no props thanks to typing of the `plugins` intersected function
|
||||
export type FunctionRet<T> = Array<(...props: any[] | never) => T>;
|
||||
|
||||
/**
|
||||
* This conditional cannot be flipped. TS assumes that Q is `WellFormed` even
|
||||
* it does not have the `class` or `constant` props. As a result, it will end
|
||||
* up `undefined`. Because we're always extending `IllformedPlugin` on the
|
||||
* plugins, this should work fine
|
||||
*/
|
||||
export type GetPluginVal<Q> = Q extends Required<{class: any}> | Required<{constants: any}>
|
||||
? WellFormedValues<Q>
|
||||
: Q;
|
||||
|
||||
export type GetPluginConst<Q> = Q extends Required<{class: any}> | Required<{constants: any}>
|
||||
? WellFormedConstants<Q>
|
||||
: {};
|
||||
|
||||
export type GetPluginDecoders<Q> = Q extends Required<{class: any}> | Required<{constants: any}>
|
||||
? Q extends {decoders: infer Decoders} ? Decoders : {} : {};
|
||||
|
||||
export type GetPluginEncoders<Q> = Q extends Required<{class: any}> | Required<{constants: any}>
|
||||
? Q extends {encoders: infer Encoders} ? Encoders : {} : {};
|
||||
|
||||
type GetPluginFuncArrValues<PluginFuncArr> =
|
||||
// Given an array of types infer `Q` (Q should be the type value)
|
||||
PluginFuncArr extends ReadonlyArray<infer F> ? F extends () => infer Q
|
||||
? // Get the plugin value, may be ill-formed or well-formed
|
||||
GetPluginVal<Q>
|
||||
: // This should never be reached
|
||||
undefined : undefined;
|
||||
|
||||
/**
|
||||
* A helper type to get the values to be intersected with `Jimp` to give
|
||||
* the proper typing given an array of functions for plugins and types
|
||||
*/
|
||||
export type GetIntersectionFromPlugins<
|
||||
PluginFuncArr extends FunctionRet<JimpPlugin | JimpType>
|
||||
> = UnionToIntersection<Exclude<GetPluginFuncArrValues<PluginFuncArr>, undefined>>;
|
||||
|
||||
type GetPluginFuncArrConsts<PluginFuncArr> =
|
||||
// Given an array of types infer `Q` (Q should be the type value)
|
||||
PluginFuncArr extends ReadonlyArray<infer F> ? F extends () => infer Q
|
||||
? // Get the plugin constants, may be ill-formed or well-formed
|
||||
GetPluginConst<Q>
|
||||
: // This should never be reached
|
||||
undefined : undefined;
|
||||
|
||||
type GetPluginFuncArrEncoders<PluginFuncArr> =
|
||||
// Given an array of types infer `Q` (Q should be the type value)
|
||||
PluginFuncArr extends ReadonlyArray<infer F> ? F extends () => infer Q
|
||||
? // Get the plugin encoders, may be ill-formed or well-formed
|
||||
GetPluginEncoders<Q>
|
||||
: // This should never be reached
|
||||
undefined : undefined;
|
||||
|
||||
type GetPluginFuncArrDecoders<PluginFuncArr> =
|
||||
// Given an array of types infer `Q` (Q should be the type value)
|
||||
PluginFuncArr extends ReadonlyArray<infer F> ? F extends () => infer Q
|
||||
? // Get the plugin decoders, may be ill-formed or well-formed
|
||||
GetPluginDecoders<Q>
|
||||
: // This should never be reached
|
||||
undefined : undefined;
|
||||
|
||||
/**
|
||||
* A helper type to get the statics to be intersected with `Jimp` to give
|
||||
* the proper typing given an array of functions for plugins and types
|
||||
*/
|
||||
export type GetIntersectionFromPluginsStatics<
|
||||
PluginFuncArr extends FunctionRet<JimpPlugin | JimpType>
|
||||
> = UnionToIntersection<GetPluginFuncArrConsts<PluginFuncArr>> & {
|
||||
encoders: UnionToIntersection<GetPluginFuncArrEncoders<PluginFuncArr>>;
|
||||
decoders: UnionToIntersection<GetPluginFuncArrDecoders<PluginFuncArr>>;
|
||||
};
|
||||
|
||||
/**
|
||||
* While this was added to TS 3.5, in order to support down to TS 2.8, we need
|
||||
* to export this and use it in sub-packges that utilize it
|
||||
*/
|
||||
export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
Reference in New Issue
Block a user