@jimp/plugin-threshold 0.22.11--canary.c55989b.0 → 0.22.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _utils = require("@jimp/utils");
8
+ /**
9
+ * Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default
10
+ * @param {number} options object
11
+ * max: A number auto limited between 0 - 255
12
+ * replace: (optional) A number auto limited between 0 - 255 (default 255)
13
+ * autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)
14
+ * @param {number} cb (optional) a callback for when complete
15
+ * @return {this} this for chaining of methods
16
+ */
17
+ var _default = () => ({
18
+ threshold(_ref, cb) {
19
+ let {
20
+ max,
21
+ replace = 255,
22
+ autoGreyscale = true
23
+ } = _ref;
24
+ if (typeof max !== "number") {
25
+ return _utils.throwError.call(this, "max must be a number", cb);
26
+ }
27
+ if (typeof replace !== "number") {
28
+ return _utils.throwError.call(this, "replace must be a number", cb);
29
+ }
30
+ if (typeof autoGreyscale !== "boolean") {
31
+ return _utils.throwError.call(this, "autoGreyscale must be a boolean", cb);
32
+ }
33
+ max = this.constructor.limit255(max);
34
+ replace = this.constructor.limit255(replace);
35
+ if (autoGreyscale) {
36
+ this.greyscale();
37
+ }
38
+ this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, (x, y, idx) => {
39
+ const grey = this.bitmap.data[idx] < max ? this.bitmap.data[idx] : replace;
40
+ this.bitmap.data[idx] = grey;
41
+ this.bitmap.data[idx + 1] = grey;
42
+ this.bitmap.data[idx + 2] = grey;
43
+ });
44
+ if ((0, _utils.isNodePattern)(cb)) {
45
+ cb.call(this, null, this);
46
+ }
47
+ return this;
48
+ }
49
+ });
50
+ exports.default = _default;
51
+ module.exports = exports.default;
52
+ module.exports.default = exports.default;
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["threshold","cb","max","replace","autoGreyscale","throwError","call","constructor","limit255","greyscale","scanQuiet","bitmap","width","height","x","y","idx","grey","data","isNodePattern"],"sources":["../src/index.js"],"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"],"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARA,eASe,OAAO;EACpBA,SAAS,OAA+CC,EAAE,EAAE;IAAA,IAAlD;MAAEC,GAAG;MAAEC,OAAO,GAAG,GAAG;MAAEC,aAAa,GAAG;IAAK,CAAC;IACpD,IAAI,OAAOF,GAAG,KAAK,QAAQ,EAAE;MAC3B,OAAOG,iBAAU,CAACC,IAA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b;AACF,CAAC,CAAC;AAAA;AAAA;AAAA"}
package/es/index.js ADDED
@@ -0,0 +1,45 @@
1
+ import { isNodePattern, throwError } from "@jimp/utils";
2
+
3
+ /**
4
+ * Applies a minimum color threshold to a greyscale image. Converts image to greyscale by default
5
+ * @param {number} options object
6
+ * max: A number auto limited between 0 - 255
7
+ * replace: (optional) A number auto limited between 0 - 255 (default 255)
8
+ * autoGreyscale: (optional) A boolean whether to apply greyscale beforehand (default true)
9
+ * @param {number} cb (optional) a callback for when complete
10
+ * @return {this} this for chaining of methods
11
+ */
12
+ export default (() => ({
13
+ threshold(_ref, cb) {
14
+ let {
15
+ max,
16
+ replace = 255,
17
+ autoGreyscale = true
18
+ } = _ref;
19
+ if (typeof max !== "number") {
20
+ return throwError.call(this, "max must be a number", cb);
21
+ }
22
+ if (typeof replace !== "number") {
23
+ return throwError.call(this, "replace must be a number", cb);
24
+ }
25
+ if (typeof autoGreyscale !== "boolean") {
26
+ return throwError.call(this, "autoGreyscale must be a boolean", cb);
27
+ }
28
+ max = this.constructor.limit255(max);
29
+ replace = this.constructor.limit255(replace);
30
+ if (autoGreyscale) {
31
+ this.greyscale();
32
+ }
33
+ this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, (x, y, idx) => {
34
+ const grey = this.bitmap.data[idx] < max ? this.bitmap.data[idx] : replace;
35
+ this.bitmap.data[idx] = grey;
36
+ this.bitmap.data[idx + 1] = grey;
37
+ this.bitmap.data[idx + 2] = grey;
38
+ });
39
+ if (isNodePattern(cb)) {
40
+ cb.call(this, null, this);
41
+ }
42
+ return this;
43
+ }
44
+ }));
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["isNodePattern","throwError","threshold","cb","max","replace","autoGreyscale","call","constructor","limit255","greyscale","scanQuiet","bitmap","width","height","x","y","idx","grey","data"],"sources":["../src/index.js"],"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"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;EACpBC,SAAS,OAA+CC,EAAE,EAAE;IAAA,IAAlD;MAAEC,GAAG;MAAEC,OAAO,GAAG,GAAG;MAAEC,aAAa,GAAG;IAAK,CAAC;IACpD,IAAI,OAAOF,GAAG,KAAK,QAAQ,EAAE;MAC3B,OAAOH,UAAU,CAACM,IAAI,CAAC,IAAI,EAAE,sBAAsB,EAAEJ,EAAE,CAAC;IAC1D;IAEA,IAAI,OAAOE,OAAO,KAAK,QAAQ,EAAE;MAC/B,OAAOJ,UAAU,CAACM,IAAI,CAAC,IAAI,EAAE,0BAA0B,EAAEJ,EAAE,CAAC;IAC9D;IAEA,IAAI,OAAOG,aAAa,KAAK,SAAS,EAAE;MACtC,OAAOL,UAAU,CAACM,IAAI,CAAC,IAAI,EAAE,iCAAiC,EAAEJ,EAAE,CAAC;IACrE;IAEAC,GAAG,GAAG,IAAI,CAACI,WAAW,CAACC,QAAQ,CAACL,GAAG,CAAC;IACpCC,OAAO,GAAG,IAAI,CAACG,WAAW,CAACC,QAAQ,CAACJ,OAAO,CAAC;IAE5C,IAAIC,aAAa,EAAE;MACjB,IAAI,CAACI,SAAS,EAAE;IAClB;IAEA,IAAI,CAACC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAACC,MAAM,CAACC,KAAK,EAAE,IAAI,CAACD,MAAM,CAACE,MAAM,EAAE,CAACC,CAAC,EAAEC,CAAC,EAAEC,GAAG,KAAK;MACzE,MAAMC,IAAI,GACR,IAAI,CAACN,MAAM,CAACO,IAAI,CAACF,GAAG,CAAC,GAAGb,GAAG,GAAG,IAAI,CAACQ,MAAM,CAACO,IAAI,CAACF,GAAG,CAAC,GAAGZ,OAAO;MAE/D,IAAI,CAACO,MAAM,CAACO,IAAI,CAACF,GAAG,CAAC,GAAGC,IAAI;MAC5B,IAAI,CAACN,MAAM,CAACO,IAAI,CAACF,GAAG,GAAG,CAAC,CAAC,GAAGC,IAAI;MAChC,IAAI,CAACN,MAAM,CAACO,IAAI,CAACF,GAAG,GAAG,CAAC,CAAC,GAAGC,IAAI;IAClC,CAAC,CAAC;IAEF,IAAIlB,aAAa,CAACG,EAAE,CAAC,EAAE;MACrBA,EAAE,CAACI,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;IAC3B;IAEA,OAAO,IAAI;EACb;AACF,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jimp/plugin-threshold",
3
- "version": "0.22.11--canary.c55989b.0",
3
+ "version": "0.22.12",
4
4
  "description": "Lightens an image.",
5
5
  "main": "dist/index.js",
6
6
  "module": "es/index.js",
@@ -21,7 +21,7 @@
21
21
  "author": "",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@jimp/utils": "0.22.11--canary.c55989b.0"
24
+ "@jimp/utils": "^0.22.12"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@jimp/custom": ">=0.3.5",
@@ -29,14 +29,14 @@
29
29
  "@jimp/plugin-resize": ">=0.8.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@jimp/custom": "0.22.11--canary.c55989b.0",
33
- "@jimp/jpeg": "0.22.11--canary.c55989b.0",
34
- "@jimp/plugin-color": "0.22.11--canary.c55989b.0",
35
- "@jimp/plugin-resize": "0.22.11--canary.c55989b.0",
36
- "@jimp/test-utils": "0.22.11--canary.c55989b.0"
32
+ "@jimp/custom": "^0.22.12",
33
+ "@jimp/jpeg": "^0.22.12",
34
+ "@jimp/plugin-color": "^0.22.12",
35
+ "@jimp/plugin-resize": "^0.22.12",
36
+ "@jimp/test-utils": "^0.22.12"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "c55989b09f4c40aaf607203a2b7069625f1ca590"
41
+ "gitHead": "a4a8d6364bbf97629749e196f3b0a4c94c9a7abc"
42
42
  }