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

23
node_modules/@jimp/plugin-normalize/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,23 @@
# 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.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-normalize/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.

24
node_modules/@jimp/plugin-normalize/README.md generated vendored Normal file
View File

@ -0,0 +1,24 @@
<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-normalize</h1>
<p>Normalize an image's colors.</p>
</div>
Normalizes an images color by computing a histogram.
## Usage
- @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.normalize();
}
main();
```

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

@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _utils = require("@jimp/utils");
/**
* Get an image's histogram
* @return {object} An object with an array of color occurrence counts for each channel (r,g,b)
*/
function histogram() {
var histogram = {
r: new Array(256).fill(0),
g: new Array(256).fill(0),
b: new Array(256).fill(0)
};
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, index) {
histogram.r[this.bitmap.data[index + 0]]++;
histogram.g[this.bitmap.data[index + 1]]++;
histogram.b[this.bitmap.data[index + 2]]++;
});
return histogram;
}
/**
* Normalize values
* @param {integer} value Pixel channel value.
* @param {integer} min Minimum value for channel
* @param {integer} max Maximum value for channel
* @return {integer} normalized values
*/
var _normalize = function normalize(value, min, max) {
return (value - min) * 255 / (max - min);
};
var getBounds = function getBounds(histogramChannel) {
return [histogramChannel.findIndex(function (value) {
return value > 0;
}), 255 - histogramChannel.slice().reverse().findIndex(function (value) {
return value > 0;
})];
};
/**
* Normalizes the image
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
var _default = function _default() {
return {
normalize: function normalize(cb) {
var h = histogram.call(this); // store bounds (minimum and maximum values)
var bounds = {
r: getBounds(h.r),
g: getBounds(h.g),
b: getBounds(h.b)
}; // apply value transformations
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
var r = this.bitmap.data[idx + 0];
var g = this.bitmap.data[idx + 1];
var b = this.bitmap.data[idx + 2];
this.bitmap.data[idx + 0] = _normalize(r, bounds.r[0], bounds.r[1]);
this.bitmap.data[idx + 1] = _normalize(g, bounds.g[0], bounds.g[1]);
this.bitmap.data[idx + 2] = _normalize(b, bounds.b[0], bounds.b[1]);
});
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
}
};
};
exports["default"] = _default;
module.exports = exports.default;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

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

@ -0,0 +1,84 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _utils = require("@jimp/utils");
/**
* Get an image's histogram
* @return {object} An object with an array of color occurrence counts for each channel (r,g,b)
*/
function histogram() {
var histogram = {
r: new Array(256).fill(0),
g: new Array(256).fill(0),
b: new Array(256).fill(0)
};
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, index) {
histogram.r[this.bitmap.data[index + 0]]++;
histogram.g[this.bitmap.data[index + 1]]++;
histogram.b[this.bitmap.data[index + 2]]++;
});
return histogram;
}
/**
* Normalize values
* @param {integer} value Pixel channel value.
* @param {integer} min Minimum value for channel
* @param {integer} max Maximum value for channel
* @return {integer} normalized values
*/
var _normalize = function normalize(value, min, max) {
return (value - min) * 255 / (max - min);
};
var getBounds = function getBounds(histogramChannel) {
return [histogramChannel.findIndex(function (value) {
return value > 0;
}), 255 - histogramChannel.slice().reverse().findIndex(function (value) {
return value > 0;
})];
};
/**
* Normalizes the image
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
var _default = function _default() {
return {
normalize: function normalize(cb) {
var h = histogram.call(this); // store bounds (minimum and maximum values)
var bounds = {
r: getBounds(h.r),
g: getBounds(h.g),
b: getBounds(h.b)
}; // apply value transformations
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function (x, y, idx) {
var r = this.bitmap.data[idx + 0];
var g = this.bitmap.data[idx + 1];
var b = this.bitmap.data[idx + 2];
this.bitmap.data[idx + 0] = _normalize(r, bounds.r[0], bounds.r[1]);
this.bitmap.data[idx + 1] = _normalize(g, bounds.g[0], bounds.g[1]);
this.bitmap.data[idx + 2] = _normalize(b, bounds.b[0], bounds.b[1]);
});
if ((0, _utils.isNodePattern)(cb)) {
cb.call(this, null, this);
}
return this;
}
};
};
exports["default"] = _default;
//# sourceMappingURL=index.js.map

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

File diff suppressed because one or more lines are too long

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

@ -0,0 +1,7 @@
import { ImageCallback } from '@jimp/core';
interface Normalize {
normalize(cb ?: ImageCallback<this>): this;
}
export default function(): Normalize;

37
node_modules/@jimp/plugin-normalize/package.json generated vendored Normal file
View File

@ -0,0 +1,37 @@
{
"name": "@jimp/plugin-normalize",
"version": "0.12.1",
"description": "normalize 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"
},
"devDependencies": {
"@jimp/custom": "^0.12.1",
"@jimp/test-utils": "^0.12.1"
},
"publishConfig": {
"access": "public"
},
"gitHead": "942e635564e36fc243767531b4f8be036afa40b5"
}

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

@ -0,0 +1,86 @@
import { isNodePattern } from '@jimp/utils';
/**
* Get an image's histogram
* @return {object} An object with an array of color occurrence counts for each channel (r,g,b)
*/
function histogram() {
const histogram = {
r: new Array(256).fill(0),
g: new Array(256).fill(0),
b: new Array(256).fill(0)
};
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function(
x,
y,
index
) {
histogram.r[this.bitmap.data[index + 0]]++;
histogram.g[this.bitmap.data[index + 1]]++;
histogram.b[this.bitmap.data[index + 2]]++;
});
return histogram;
}
/**
* Normalize values
* @param {integer} value Pixel channel value.
* @param {integer} min Minimum value for channel
* @param {integer} max Maximum value for channel
* @return {integer} normalized values
*/
const normalize = function(value, min, max) {
return ((value - min) * 255) / (max - min);
};
const getBounds = function(histogramChannel) {
return [
histogramChannel.findIndex(value => value > 0),
255 -
histogramChannel
.slice()
.reverse()
.findIndex(value => value > 0)
];
};
/**
* Normalizes the image
* @param {function(Error, Jimp)} cb (optional) a callback for when complete
* @returns {Jimp} this for chaining of methods
*/
export default () => ({
normalize(cb) {
const h = histogram.call(this);
// store bounds (minimum and maximum values)
const bounds = {
r: getBounds(h.r),
g: getBounds(h.g),
b: getBounds(h.b)
};
// apply value transformations
this.scanQuiet(0, 0, this.bitmap.width, this.bitmap.height, function(
x,
y,
idx
) {
const r = this.bitmap.data[idx + 0];
const g = this.bitmap.data[idx + 1];
const b = this.bitmap.data[idx + 2];
this.bitmap.data[idx + 0] = normalize(r, bounds.r[0], bounds.r[1]);
this.bitmap.data[idx + 1] = normalize(g, bounds.g[0], bounds.g[1]);
this.bitmap.data[idx + 2] = normalize(b, bounds.b[0], bounds.b[1]);
});
if (isNodePattern(cb)) {
cb.call(this, null, this);
}
return this;
}
});

View File

@ -0,0 +1,48 @@
import { Jimp, mkJGD } from '@jimp/test-utils';
import configure from '@jimp/custom';
import normalize from '../src';
const jimp = configure({ plugins: [normalize] }, Jimp);
describe('Normalize', () => {
it('change grayscale image', async () => {
const image = await jimp.read(mkJGD('36▦', '6▦9', '▦9C'));
image
.normalize()
.getJGDSync()
.should.be.sameJGD(mkJGD('■5▦', '5▦A', '▦A□'));
});
it('change red/blue image', async () => {
const image = await jimp.read({
width: 3,
height: 2,
data: [
0x000000ff,
0x400022ff,
0x40002200,
0x400000ff,
0x000022ff,
0x800055ff
]
});
image
.normalize()
.getJGDSync()
.should.be.sameJGD({
width: 3,
height: 2,
data: [
0x000000ff,
0x7f0066ff,
0x7f006600,
0x7f0000ff,
0x000066ff,
0xff00ffff
]
});
});
});