This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

35
node_modules/@jimp/plugin-threshold/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,35 @@
# v0.11.0 (Fri May 15 2020)
#### 🚀 Enhancement
- Removed Core-JS as a dependency. [#882](https://github.com/oliver-moran/jimp/pull/882) ([@EricRabil](https://github.com/EricRabil))
#### Authors: 1
- Eric Rabil ([@EricRabil](https://github.com/EricRabil))
---
# v0.9.7 (Fri Mar 27 2020)
#### 🐛 Bug Fix
- Relax version range of plugin-threshold peerDependencies [#859](https://github.com/oliver-moran/jimp/pull/859) ([@pasieronen](https://github.com/pasieronen))
#### Authors: 1
- Pasi Eronen ([@pasieronen](https://github.com/pasieronen))
---
# 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))
#### Authors: 2
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
- Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))

21
node_modules/@jimp/plugin-threshold/LICENSE generated vendored Normal file
View 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.

30
node_modules/@jimp/plugin-threshold/README.md generated vendored Normal file
View File

@ -0,0 +1,30 @@
<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/plugin-threshold</h1>
<p>Lightens an image.</p>
</div>
This is useful as a simplified method for processing scanned drawings, signatures, etc
## Usage
- @param {number} options object
- max: A number auto limited between 0 - 255
- replace: (optional) A number auto limited between 0 - 255 (default 255)
- autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)
- @param {function(Error, Jimp)} cb (optional) a callback for when complete
```js
import jimp from 'jimp';
async function main() {
const image = await jimp.read('test/image.png');
image.threshold({ max: 150 });
// or
image.threshold({ max: 200, replace: 200, autoGreyscale: false });
}
main();
```

38
node_modules/@jimp/plugin-threshold/babel.config.js generated vendored Normal file
View File

@ -0,0 +1,38 @@
module.exports = api => {
api.cache(true);
return {
presets: [
[
'@babel/env',
{
useBuiltIns: 'usage'
}
]
],
plugins: [
'@babel/proposal-class-properties',
'@babel/syntax-object-rest-spread',
process.env.BABEL_ENV !== 'module' && 'add-module-exports',
[
'transform-inline-environment-variables',
{ include: ['BABEL_ENV', 'ENV'] }
]
].filter(Boolean),
env: {
test: {
plugins: ['istanbul']
},
development: {
plugins: [process.env.ENV !== 'browser' && 'source-map-support'].filter(
Boolean
)
},
module: {
presets: [['@babel/env', { modules: false }]]
}
}
};
};

67
node_modules/@jimp/plugin-threshold/dist/index.js generated vendored Normal file
View File

@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _utils = require("@jimp/utils");
/**
* Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default
* @param {number} options object
* max: A number auto limited between 0 - 255
* replace: (optional) A number auto limited between 0 - 255 (default 255)
* autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)
* @param {number} cb (optional) a callback for when complete
* @return {this} this for chaining of methods
*/
var _default = function _default() {
return {
threshold: function threshold(_ref, cb) {
var _this = this;
var max = _ref.max,
_ref$replace = _ref.replace,
replace = _ref$replace === void 0 ? 255 : _ref$replace,
_ref$autoGreyscale = _ref.autoGreyscale,
autoGreyscale = _ref$autoGreyscale === void 0 ? true : _ref$autoGreyscale;
if (typeof max !== 'number') {
return _utils.throwError.call(this, 'max must be a number', cb);
}
if (typeof replace !== 'number') {
return _utils.throwError.call(this, 'replace must be a number', cb);
}
if (typeof autoGreyscale !== 'boolean') {
return _utils.throwError.call(this, 'autoGreyscale must be a boolean', cb);
}
max = this.constructor.limit255(max);
replace = this.constructor.limit255(replace);
if (autoGreyscale) {
this.greyscale();
}
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
var grey = _this.bitmap.data[idx] < max ? _this.bitmap.data[idx] : replace;
_this.bitmap.data[idx] = grey;
_this.bitmap.data[idx + 1] = grey;
_this.bitmap.data[idx + 2] = grey;
});
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
}
};
};
exports["default"] = _default;
module.exports = exports.default;
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../src/index.js"],"names":["threshold","cb","max","replace","autoGreyscale","throwError","call","constructor","limit255","greyscale","scanQuiet","bitmap","width","height","x","y","idx","grey","data"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;;;;eASe;AAAA,SAAO;AACpBA,IAAAA,SADoB,2BACoCC,EADpC,EACwC;AAAA;;AAAA,UAAhDC,GAAgD,QAAhDA,GAAgD;AAAA,8BAA3CC,OAA2C;AAAA,UAA3CA,OAA2C,6BAAjC,GAAiC;AAAA,oCAA5BC,aAA4B;AAAA,UAA5BA,aAA4B,mCAAZ,IAAY;;AAC1D,UAAI,OAAOF,GAAP,KAAe,QAAnB,EAA6B;AAC3B,eAAOG,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,sBAAtB,EAA8CL,EAA9C,CAAP;AACD;;AAED,UAAI,OAAOE,OAAP,KAAmB,QAAvB,EAAiC;AAC/B,eAAOE,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,0BAAtB,EAAkDL,EAAlD,CAAP;AACD;;AAED,UAAI,OAAOG,aAAP,KAAyB,SAA7B,EAAwC;AACtC,eAAOC,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,iCAAtB,EAAyDL,EAAzD,CAAP;AACD;;AAEDC,MAAAA,GAAG,GAAG,KAAKK,WAAL,CAAiBC,QAAjB,CAA0BN,GAA1B,CAAN;AACAC,MAAAA,OAAO,GAAG,KAAKI,WAAL,CAAiBC,QAAjB,CAA0BL,OAA1B,CAAV;;AAEA,UAAIC,aAAJ,EAAmB;AACjB,aAAKK,SAAL;AACD;;AAED,WAAKC,SAAL,CAAe,CAAf,EAAkB,CAAlB,EAAqB,KAAKC,MAAL,CAAYC,KAAjC,EAAwC,KAAKD,MAAL,CAAYE,MAApD,EAA4D,UAACC,CAAD,EAAIC,CAAJ,EAAOC,GAAP,EAAe;AACzE,YAAMC,IAAI,GACR,KAAI,CAACN,MAAL,CAAYO,IAAZ,CAAiBF,GAAjB,IAAwBd,GAAxB,GAA8B,KAAI,CAACS,MAAL,CAAYO,IAAZ,CAAiBF,GAAjB,CAA9B,GAAsDb,OADxD;AAGA,QAAA,KAAI,CAACQ,MAAL,CAAYO,IAAZ,CAAiBF,GAAjB,IAAwBC,IAAxB;AACA,QAAA,KAAI,CAACN,MAAL,CAAYO,IAAZ,CAAiBF,GAAG,GAAG,CAAvB,IAA4BC,IAA5B;AACA,QAAA,KAAI,CAACN,MAAL,CAAYO,IAAZ,CAAiBF,GAAG,GAAG,CAAvB,IAA4BC,IAA5B;AACD,OAPD;;AASA,UAAI,0BAAchB,EAAd,CAAJ,EAAuB;AACrBA,QAAAA,EAAE,CAACK,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AAnCmB,GAAP;AAAA,C","sourcesContent":["import { isNodePattern, throwError } from '@jimp/utils';\n\n/**\n * Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default\n * @param {number} options object\n * max: A number auto limited between 0 - 255\n * replace: (optional) A number auto limited between 0 - 255 (default 255)\n * autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)\n * @param {number} cb (optional) a callback for when complete\n * @return {this} this for chaining of methods\n */\nexport default () => ({\n threshold({ max, replace = 255, autoGreyscale = true }, cb) {\n if (typeof max !== 'number') {\n return throwError.call(this, 'max must be a number', cb);\n }\n\n if (typeof replace !== 'number') {\n return throwError.call(this, 'replace must be a number', cb);\n }\n\n if (typeof autoGreyscale !== 'boolean') {\n return throwError.call(this, 'autoGreyscale must be a boolean', cb);\n }\n\n max = this.constructor.limit255(max);\n replace = this.constructor.limit255(replace);\n\n if (autoGreyscale) {\n this.greyscale();\n }\n\n this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, (x, y, idx) => {\n const grey =\n this.bitmap.data[idx] < max ? this.bitmap.data[idx] : replace;\n\n this.bitmap.data[idx] = grey;\n this.bitmap.data[idx + 1] = grey;\n this.bitmap.data[idx + 2] = grey;\n });\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}

66
node_modules/@jimp/plugin-threshold/es/index.js generated vendored Normal file
View File

@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _utils = require("@jimp/utils");
/**
* Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default
* @param {number} options object
* max: A number auto limited between 0 - 255
* replace: (optional) A number auto limited between 0 - 255 (default 255)
* autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)
* @param {number} cb (optional) a callback for when complete
* @return {this} this for chaining of methods
*/
var _default = function _default() {
return {
threshold: function threshold(_ref, cb) {
var _this = this;
var max = _ref.max,
_ref$replace = _ref.replace,
replace = _ref$replace === void 0 ? 255 : _ref$replace,
_ref$autoGreyscale = _ref.autoGreyscale,
autoGreyscale = _ref$autoGreyscale === void 0 ? true : _ref$autoGreyscale;
if (typeof max !== 'number') {
return _utils.throwError.call(this, 'max must be a number', cb);
}
if (typeof replace !== 'number') {
return _utils.throwError.call(this, 'replace must be a number', cb);
}
if (typeof autoGreyscale !== 'boolean') {
return _utils.throwError.call(this, 'autoGreyscale must be a boolean', cb);
}
max = this.constructor.limit255(max);
replace = this.constructor.limit255(replace);
if (autoGreyscale) {
this.greyscale();
}
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
var grey = _this.bitmap.data[idx] < max ? _this.bitmap.data[idx] : replace;
_this.bitmap.data[idx] = grey;
_this.bitmap.data[idx + 1] = grey;
_this.bitmap.data[idx + 2] = grey;
});
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
}
};
};
exports["default"] = _default;
//# sourceMappingURL=index.js.map

1
node_modules/@jimp/plugin-threshold/es/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../src/index.js"],"names":["threshold","cb","max","replace","autoGreyscale","throwError","call","constructor","limit255","greyscale","scanQuiet","bitmap","width","height","x","y","idx","grey","data"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;;;;eASe;AAAA,SAAO;AACpBA,IAAAA,SADoB,2BACoCC,EADpC,EACwC;AAAA;;AAAA,UAAhDC,GAAgD,QAAhDA,GAAgD;AAAA,8BAA3CC,OAA2C;AAAA,UAA3CA,OAA2C,6BAAjC,GAAiC;AAAA,oCAA5BC,aAA4B;AAAA,UAA5BA,aAA4B,mCAAZ,IAAY;;AAC1D,UAAI,OAAOF,GAAP,KAAe,QAAnB,EAA6B;AAC3B,eAAOG,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,sBAAtB,EAA8CL,EAA9C,CAAP;AACD;;AAED,UAAI,OAAOE,OAAP,KAAmB,QAAvB,EAAiC;AAC/B,eAAOE,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,0BAAtB,EAAkDL,EAAlD,CAAP;AACD;;AAED,UAAI,OAAOG,aAAP,KAAyB,SAA7B,EAAwC;AACtC,eAAOC,kBAAWC,IAAX,CAAgB,IAAhB,EAAsB,iCAAtB,EAAyDL,EAAzD,CAAP;AACD;;AAEDC,MAAAA,GAAG,GAAG,KAAKK,WAAL,CAAiBC,QAAjB,CAA0BN,GAA1B,CAAN;AACAC,MAAAA,OAAO,GAAG,KAAKI,WAAL,CAAiBC,QAAjB,CAA0BL,OAA1B,CAAV;;AAEA,UAAIC,aAAJ,EAAmB;AACjB,aAAKK,SAAL;AACD;;AAED,WAAKC,SAAL,CAAe,CAAf,EAAkB,CAAlB,EAAqB,KAAKC,MAAL,CAAYC,KAAjC,EAAwC,KAAKD,MAAL,CAAYE,MAApD,EAA4D,UAACC,CAAD,EAAIC,CAAJ,EAAOC,GAAP,EAAe;AACzE,YAAMC,IAAI,GACR,KAAI,CAACN,MAAL,CAAYO,IAAZ,CAAiBF,GAAjB,IAAwBd,GAAxB,GAA8B,KAAI,CAACS,MAAL,CAAYO,IAAZ,CAAiBF,GAAjB,CAA9B,GAAsDb,OADxD;AAGA,QAAA,KAAI,CAACQ,MAAL,CAAYO,IAAZ,CAAiBF,GAAjB,IAAwBC,IAAxB;AACA,QAAA,KAAI,CAACN,MAAL,CAAYO,IAAZ,CAAiBF,GAAG,GAAG,CAAvB,IAA4BC,IAA5B;AACA,QAAA,KAAI,CAACN,MAAL,CAAYO,IAAZ,CAAiBF,GAAG,GAAG,CAAvB,IAA4BC,IAA5B;AACD,OAPD;;AASA,UAAI,0BAAchB,EAAd,CAAJ,EAAuB;AACrBA,QAAAA,EAAE,CAACK,IAAH,CAAQ,IAAR,EAAc,IAAd,EAAoB,IAApB;AACD;;AAED,aAAO,IAAP;AACD;AAnCmB,GAAP;AAAA,C","sourcesContent":["import { isNodePattern, throwError } from '@jimp/utils';\n\n/**\n * Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default\n * @param {number} options object\n * max: A number auto limited between 0 - 255\n * replace: (optional) A number auto limited between 0 - 255 (default 255)\n * autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)\n * @param {number} cb (optional) a callback for when complete\n * @return {this} this for chaining of methods\n */\nexport default () => ({\n threshold({ max, replace = 255, autoGreyscale = true }, cb) {\n if (typeof max !== 'number') {\n return throwError.call(this, 'max must be a number', cb);\n }\n\n if (typeof replace !== 'number') {\n return throwError.call(this, 'replace must be a number', cb);\n }\n\n if (typeof autoGreyscale !== 'boolean') {\n return throwError.call(this, 'autoGreyscale must be a boolean', cb);\n }\n\n max = this.constructor.limit255(max);\n replace = this.constructor.limit255(replace);\n\n if (autoGreyscale) {\n this.greyscale();\n }\n\n this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, (x, y, idx) => {\n const grey =\n this.bitmap.data[idx] < max ? this.bitmap.data[idx] : replace;\n\n this.bitmap.data[idx] = grey;\n this.bitmap.data[idx + 1] = grey;\n this.bitmap.data[idx + 2] = grey;\n });\n\n if (isNodePattern(cb)) {\n cb.call(this, null, this);\n }\n\n return this;\n }\n});\n"],"file":"index.js"}

11
node_modules/@jimp/plugin-threshold/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,11 @@
import { ImageCallback } from '@jimp/core';
interface Threshold {
threshold(opts: {
max: number,
replace?: number,
autoGreyscale?: boolean
}, cb?: ImageCallback<this>): this;
}
export default function(): Threshold;

42
node_modules/@jimp/plugin-threshold/package.json generated vendored Normal file
View File

@ -0,0 +1,42 @@
{
"name": "@jimp/plugin-threshold",
"version": "0.12.1",
"description": "Lightens an image.",
"main": "dist/index.js",
"module": "es/index.js",
"types": "index.d.ts",
"scripts": {
"test": "cross-env BABEL_ENV=test mocha --require @babel/register",
"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": "",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.7.2",
"@jimp/utils": "^0.12.1"
},
"peerDependencies": {
"@jimp/custom": ">=0.3.5",
"@jimp/plugin-color": ">=0.8.0",
"@jimp/plugin-resize": ">=0.8.0"
},
"devDependencies": {
"@jimp/custom": "^0.12.1",
"@jimp/jpeg": "^0.12.1",
"@jimp/plugin-color": "^0.12.1",
"@jimp/plugin-resize": "^0.12.1",
"@jimp/test-utils": "^0.12.1"
},
"publishConfig": {
"access": "public"
},
"gitHead": "942e635564e36fc243767531b4f8be036afa40b5"
}

48
node_modules/@jimp/plugin-threshold/src/index.js generated vendored Normal file
View File

@ -0,0 +1,48 @@
import { isNodePattern, throwError } from '@jimp/utils';
/**
* Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default
* @param {number} options object
* max: A number auto limited between 0 - 255
* replace: (optional) A number auto limited between 0 - 255 (default 255)
* autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)
* @param {number} cb (optional) a callback for when complete
* @return {this} this for chaining of methods
*/
export default () => ({
threshold({ max, replace = 255, autoGreyscale = true }, cb) {
if (typeof max !== 'number') {
return throwError.call(this, 'max must be a number', cb);
}
if (typeof replace !== 'number') {
return throwError.call(this, 'replace must be a number', cb);
}
if (typeof autoGreyscale !== 'boolean') {
return throwError.call(this, 'autoGreyscale must be a boolean', cb);
}
max = this.constructor.limit255(max);
replace = this.constructor.limit255(replace);
if (autoGreyscale) {
this.greyscale();
}
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, (x, y, idx) => {
const grey =
this.bitmap.data[idx] < max ? this.bitmap.data[idx] : replace;
this.bitmap.data[idx] = grey;
this.bitmap.data[idx + 1] = grey;
this.bitmap.data[idx + 2] = grey;
});
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
return this;
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 KiB

View File

@ -0,0 +1,30 @@
import { Jimp, getTestDir } from '@jimp/test-utils';
import configure from '@jimp/custom';
import jpeg from '@jimp/jpeg';
import color from '@jimp/plugin-color';
import resize from '@jimp/plugin-resize';
import threshold from '../src';
const jimp = configure(
{ types: [jpeg], plugins: [threshold, color, resize] },
Jimp
);
describe('Threshold', function() {
this.timeout(15000);
it('defines default threshold for lighter backgrounds', async () => {
const expectedImage = await jimp.read(
getTestDir(__dirname) + '/images/hands_mx200_rp255.jpg'
);
const testImage = await jimp.read(
getTestDir(__dirname) + '/images/hands.jpg'
);
testImage
.threshold({ max: 200, replace: 255 })
.hash()
.should.be.equal(expectedImage.hash());
});
});