Comparing version 0.2.21 to 0.2.22
{ | ||
"name": "jimp", | ||
"version": "0.2.21", | ||
"version": "0.2.22", | ||
"description": "An image processing library written entirely in JavaScript (i.e. zero external or native dependencies).", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "./test/tests.sh", | ||
"prepublish": "./browser/browserify-build.sh" | ||
}, | ||
@@ -29,3 +30,3 @@ "keywords": [ | ||
"file-type": "^3.1.0", | ||
"jpeg-js": "^0.1.1", | ||
"jpeg-js": "^0.1.2", | ||
"mime": "^1.3.4", | ||
@@ -40,2 +41,13 @@ "pixelmatch": "^4.0.0", | ||
}, | ||
"devDependencies": { | ||
"babel": "^6.0.14", | ||
"babel-cli": "^6.0.0", | ||
"babel-preset-es2015": "^6.0.14", | ||
"babel-preset-stage-0": "^6.0.14", | ||
"browserify": "^13.0.0", | ||
"envify": "^3.4.0", | ||
"express": "^4.13.4", | ||
"uglify-js": "^2.6.1", | ||
"uglifyify": "^3.0.1" | ||
}, | ||
"repository": { | ||
@@ -42,0 +54,0 @@ "type": "git", |
@@ -5,3 +5,3 @@ # Jimp # | ||
An image processing library for Node written entirely in JavaScript, with zero external or native dependencies. | ||
An image processing library for Node written entirely in JavaScript, with zero external or native dependencies. Install using `npm install --save jimp`. | ||
@@ -36,3 +36,5 @@ Example usage: | ||
Now also available for use in the browser for image manipulation in web workers without `<canvas>`. See [`browser/README.md`](https://github.com/oliver-moran/jimp/blob/master/browser/README.md). | ||
## Basic usage ## | ||
@@ -56,3 +58,2 @@ | ||
```js | ||
@@ -82,4 +83,5 @@ Jimp.read(lenna.buffer, function (err, image) { | ||
image.opacity( f ); // multiply the alpha channel by each pixel by the factor f, 0 - 1 | ||
image.resize( w, h ); // resize the image. Jimp.AUTO can be passed as one of the values. | ||
image.resize( w, h[, mode] ); // resize the image. Jimp.AUTO can be passed as one of the values. Optionally, a resize mode can be passed. | ||
image.scale( f ); // scale the image by the factor f | ||
image.scaleToFit( w, h ); // scale the image to the largest size that fits inside the given width and height | ||
image.rotate( deg[, resize] ); // rotate the image clockwise by a number of degrees. Unless `false` is passed as the second parameter, the image width and height will be resized appropriately. | ||
@@ -94,4 +96,4 @@ image.blit( src, x, y[, srcx, srcy, srcw, srch] ); | ||
image.dither565(); // ordered dithering of the image and reduce color space to 16-bits (RGB565) | ||
image.cover( w, h ); // scale the image so that it fills the given width and height | ||
image.contain( w, h ); // scale the image to the largest size so that fits inside the given width and height | ||
image.cover( w, h ); // scale the image to the given width and height, some parts of the image may be clipped | ||
image.contain( w, h ); // scale the image to the given width and height, some parts of the image may be letter boxed | ||
image.background( hex ); // set the default new pixel colour (e.g. 0xFFFFFFFF or 0x00000000) for by some operations (e.g. image.contain and image.rotate) and when writing formats that don't support alpha channels | ||
@@ -106,2 +108,28 @@ image.mirror( horz, vert ); // an alias for flip | ||
### Resize modes ### | ||
The default rezing algorithm uses a bilinear method as follows: | ||
```js | ||
image.resize(250, 250); // resize the image to 250 x 250 | ||
image.resize(Jimp.AUTO, 250); // resize the height to 250 and scale the width accordingly | ||
image.resize(250, Jimp.AUTO); // resize the width to 250 and scale the height accordingly | ||
``` | ||
Optionally, the following constants can be passed to choose a particular resizing algorithm: | ||
```js | ||
Jimp.RESIZE_NEAREST_NEIGHBOR; | ||
Jimp.RESIZE_BILINEAR; | ||
Jimp.RESIZE_BICUBIC; | ||
Jimp.RESIZE_HERMITE; | ||
Jimp.RESIZE_BEZIER; | ||
``` | ||
For example: | ||
```js | ||
image.resize(250, 250, Jimp.RESIZE_BEZIER); | ||
``` | ||
## Writing to files and buffers ## | ||
@@ -276,5 +304,5 @@ | ||
There are 18,446,744,073,709,551,615 unique hashes. The hammering distance between the binary representation of these hashes can be used to find similar-looking images. | ||
There are 18,446,744,073,709,551,615 unique hashes. The hamming distance between the binary representation of these hashes can be used to find similar-looking images. | ||
To calculate the hammering distance between two Jimp images based on their perceptual hash use: | ||
To calculate the hamming distance between two Jimp images based on their perceptual hash use: | ||
@@ -293,3 +321,3 @@ ```js | ||
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. | ||
Using a mix of hamming 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. | ||
@@ -296,0 +324,0 @@ ```js |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
2181477
25
8888
354
9
19
5
Updatedjpeg-js@^0.1.2