Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jimp/plugin-normalize

Package Overview
Dependencies
Maintainers
2
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jimp/plugin-normalize - npm Package Compare versions

Comparing version 0.16.3-canary.1125.1580.0 to 0.16.3

16

CHANGELOG.md

@@ -0,1 +1,13 @@

# v0.16.3 (Sat Feb 04 2023)
#### ⚠️ Pushed to `master`
- upgrade prettier ([@hipstersmoothie](https://github.com/hipstersmoothie))
#### Authors: 1
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
---
# v0.11.0 (Fri May 15 2020)

@@ -15,3 +27,3 @@

#### 🐛 Bug Fix
#### 🐛 Bug Fix

@@ -24,2 +36,2 @@ - `@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`

- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
- Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))
- Corbin Crutchley ([@crutchcorn](https://github.com/crutchcorn))

6

index.d.ts

@@ -1,7 +0,7 @@

import { ImageCallback } from '@jimp/core';
import { ImageCallback } from "@jimp/core";
interface Normalize {
normalize(cb ?: ImageCallback<this>): this;
normalize(cb?: ImageCallback<this>): this;
}
export default function(): Normalize;
export default function (): Normalize;
{
"name": "@jimp/plugin-normalize",
"version": "0.16.3-canary.1125.1580.0",
"version": "0.16.3",
"description": "normalize an image.",

@@ -24,3 +24,3 @@ "main": "dist/index.js",

"@babel/runtime": "^7.7.2",
"@jimp/utils": "0.16.3-canary.1125.1580.0"
"@jimp/utils": "^0.16.3"
},

@@ -31,4 +31,4 @@ "peerDependencies": {

"devDependencies": {
"@jimp/custom": "0.16.3-canary.1125.1580.0",
"@jimp/test-utils": "0.16.3-canary.1125.1580.0"
"@jimp/custom": "^0.16.3",
"@jimp/test-utils": "^0.16.3"
},

@@ -38,3 +38,3 @@ "publishConfig": {

},
"gitHead": "bfdb98aaf820272c06e332483b943d0ac58659db"
"gitHead": "b9ac83d855d09deecde129a9c9b5b328ba7ea5b2"
}

@@ -15,6 +15,6 @@ <div align="center">

```js
import jimp from 'jimp';
import jimp from "jimp";
async function main() {
const image = await jimp.read('test/image.png');
const image = await jimp.read("test/image.png");

@@ -21,0 +21,0 @@ image.normalize();

@@ -1,2 +0,2 @@

import { isNodePattern } from '@jimp/utils';
import { isNodePattern } from "@jimp/utils";

@@ -11,14 +11,16 @@ /**

g: new Array(256).fill(0),
b: 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]]++;
});
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]]++;
}
);

@@ -35,9 +37,9 @@ return histogram;

*/
const normalize = function(value, min, max) {
const normalize = function (value, min, max) {
return ((value - min) * 255) / (max - min);
};
const getBounds = function(histogramChannel) {
const getBounds = function (histogramChannel) {
return [
histogramChannel.findIndex(value => value > 0),
histogramChannel.findIndex((value) => value > 0),
255 -

@@ -47,3 +49,3 @@ histogramChannel

.reverse()
.findIndex(value => value > 0)
.findIndex((value) => value > 0),
];

@@ -65,19 +67,21 @@ };

g: getBounds(h.g),
b: getBounds(h.b)
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.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]);
});
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]);
}
);

@@ -89,3 +93,3 @@ if (isNodePattern(cb)) {

return this;
}
},
});

@@ -1,11 +0,11 @@

import { Jimp, mkJGD } from '@jimp/test-utils';
import configure from '@jimp/custom';
import { Jimp, mkJGD } from "@jimp/test-utils";
import configure from "@jimp/custom";
import normalize from '../src';
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'));
describe("Normalize", () => {
it("change grayscale image", async () => {
const image = await jimp.read(mkJGD("36▦", "6▦9", "▦9C"));

@@ -15,6 +15,6 @@ image

.getJGDSync()
.should.be.sameJGD(mkJGD('■5▦', '5▦A', '▦A□'));
.should.be.sameJGD(mkJGD("■5▦", "5▦A", "▦A□"));
});
it('change red/blue image', async () => {
it("change red/blue image", async () => {
const image = await jimp.read({

@@ -24,9 +24,4 @@ width: 3,

data: [
0x000000ff,
0x400022ff,
0x40002200,
0x400000ff,
0x000022ff,
0x800055ff
]
0x000000ff, 0x400022ff, 0x40002200, 0x400000ff, 0x000022ff, 0x800055ff,
],
});

@@ -41,11 +36,7 @@

data: [
0x000000ff,
0x7f0066ff,
0x7f006600,
0x7f0000ff,
0x000066ff,
0xff00ffff
]
0x000000ff, 0x7f0066ff, 0x7f006600, 0x7f0000ff, 0x000066ff,
0xff00ffff,
],
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc