Comparing version 0.2.19 to 0.2.20
{ | ||
"name": "jimp", | ||
"version": "0.2.19", | ||
"version": "0.2.20", | ||
"description": "An image processing library written entirely in JavaScript (i.e. zero external or native dependencies).", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -26,6 +26,6 @@ # Jimp # | ||
Jimp.read("lenna.png").then(function (lenna) { | ||
lenna.resize(256, 256) // resize | ||
.quality(60) // set JPEG quality | ||
.greyscale() // set greyscale | ||
.write("lena-small-bw.jpg") // save | ||
lenna.resize(256, 256) // resize | ||
.quality(60) // set JPEG quality | ||
.greyscale() // set greyscale | ||
.write("lena-small-bw.jpg"); // save | ||
}).catch(function (err) { | ||
@@ -72,2 +72,3 @@ console.error(err); | ||
image.crop( x, y, w, h ); // crop to the given region | ||
image.autocrop(); // automatically crop same-color borders from image (if any) | ||
image.invert(); // invert the image colours | ||
@@ -214,6 +215,6 @@ image.flip( horz, vert ); // flip the image horizontally or vertically | ||
var red = this.bitmap.data[idx]; | ||
var green = this.bitmap.data[idx+1]; | ||
var blue = this.bitmap.data[idx+2]; | ||
var alpha = this.bitmap.data[idx+3]; | ||
var red = this.bitmap.data[ idx + 0 ]; | ||
var green = this.bitmap.data[ idx + 1 ]; | ||
var blue = this.bitmap.data[ idx + 2 ]; | ||
var alpha = this.bitmap.data[ idx + 3 ]; | ||
@@ -276,3 +277,3 @@ // rgba values run from 0 - 255 | ||
```js | ||
Jimp.distance(image1, image2); // returns a number 0-1, where 0 means the two images are percieved to be identical | ||
Jimp.distance(image1, image2); // returns a number 0-1, where 0 means the two images are perceived to be identical | ||
``` | ||
@@ -288,10 +289,8 @@ | ||
Using a mix of hammering distance and pixel diffing to comare images, the following code has a 99% success rate of detecting the same image from a random sample (with 1% false positives). The test this figure is drawn from attempts to match each image from sample of 120 PNGs against 120 corresponing JPEGs saved at a quality setting of 60. | ||
Using a mix of hammering distance and pixel diffing to comare images, the following code has a 99% success rate of detecting the same image from a random sample (with 1% false positives). The test this figure is drawn from attempts to match each image from a sample of 120 PNGs against 120 corresponing JPEGs saved at a quality setting of 60. | ||
```js | ||
var distance = Jimp.distance(png, jpeg); // percieved distance | ||
var distance = Jimp.distance(png, jpeg); // perceived distance | ||
var diff = Jimp.diff(png, jpeg); // pixel difference | ||
var jpeg_r = jpeg.clone().resize(png.bitmap.width, png.bitmap.height); | ||
var diff = Jimp.diff(png, jpeg_r); // pixel difference | ||
if (distance < 0.15 || diff.percent < 0.15) { | ||
@@ -298,0 +297,0 @@ // images match |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
107457
2084
325