@jimp/plugin-color
Bitmap manipulation to adjust the color in an image.
Last updated 3 years ago by alisowski .
MIT · Original npm · Tarball · package.json
$ npm install @jimp/plugin-color 
SYNC missed versions from official npm registry.

@jimp/plugin-color

Jimp color methods.

Bitmap manipulation to adjust the color in an image.

color

Apply multiple color modification rules

  • @param {array} actions list of color modification rules, in following format: { apply: '<rule-name>', params: [ <rule-parameters> ] }
  • @param {function(Error, Jimp)} cb (optional) a callback for when complete
import jimp from 'jimp';

async function main() {
  const image = await jimp.read('test/image.png');

  image.color([{ apply: 'red', params: [100] }]);
}

main();

Jimp supports advanced colour manipulation using a single method as follows:

image.color([
  { apply: 'hue', params: [-90] },
  { apply: 'lighten', params: [50] },
  { apply: 'xor', params: ['#06D'] }
]);

The method supports the following modifiers:

Modifier Description
lighten {amount} Lighten the color a given amount, from 0 to 100. Providing 100 will always return white (works through TinyColor)
brighten {amount} Brighten the color a given amount, from 0 to 100 (works through TinyColor)
darken {amount} Darken the color a given amount, from 0 to 100. Providing 100 will always return black (works through TinyColor)
desaturate {amount} Desaturate the color a given amount, from 0 to 100. Providing 100 will is the same as calling greyscale (works through TinyColor)
saturate {amount} Saturate the color a given amount, from 0 to 100 (works through TinyColor)
greyscale {amount} Completely desaturates a color into greyscale (works through TinyColor)
spin {degree} Spin the hue a given amount, from -360 to 360. Calling with 0, 360, or -360 will do nothing - since it sets the hue back to what it was before. (works through TinyColor)
hue {degree} Alias for spin
mix {color, amount} Mixes colors by their RGB component values. Amount is opacity of overlaying color
tint {amount} Same as applying mix with white color
shade {amount} Same as applying mix with black color
xor {color} Treats the two colors as bitfields and applies an XOR operation to the red, green, and blue components
red {amount} Modify Red component by a given amount
green {amount} Modify Green component by a given amount
blue {amount} Modify Blue component by a given amount

brightness

Adjusts the brightness of the image

  • @param {number} val the amount to adjust the brightness, a number between -1 and +1
  • @param {function(Error, Jimp)} cb (optional) a callback for when complete
import jimp from 'jimp';

async function main() {
  const image = await jimp.read('test/image.png');

  image.brightness(20);
}

main();

contrast

Adjusts the contrast of the image

  • @param {number} val the amount to adjust the contrast, a number between -1 and +1
  • @param {function(Error, Jimp)} cb (optional) a callback for when complete
import jimp from 'jimp';

async function main() {
  const image = await jimp.read('test/image.png');

  image.contrast(70);
}

main();

posterize

Apply a posterize effect

  • @param {number} n the amount to adjust the contrast, minimum threshold is two
  • @param {function(Error, Jimp)} cb (optional) a callback for when complete
import jimp from 'jimp';

async function main() {
  const image = await jimp.read('test/image.png');

  image.posterize(5);
}

main();

opacity

Multiplies the opacity of each pixel by a factor between 0 and 1

  • @param {number} f A number, the factor by which to multiply the opacity of each pixel
  • @param {function(Error, Jimp)} cb (optional) a callback for when complete
import jimp from 'jimp';

async function main() {
  const image = await jimp.read('test/image.png');

  image.opacity(80);
}

main();

sepia

Applies a sepia tone to the image

  • @param {function(Error, Jimp)} cb (optional) a callback for when complete
import jimp from 'jimp';

async function main() {
  const image = await jimp.read('test/image.png');

  image.sepia();
}

main();

fade

Fades each pixel by a factor between 0 and 1

  • @param {number} f A number from 0 to 1. 0 will haven no effect. 1 will turn the image completely transparent.
  • @param {function(Error, Jimp)} cb (optional) a callback for when complete
import jimp from 'jimp';

async function main() {
  const image = await jimp.read('test/image.png');

  image.fade(0.7);
}

main();

convolution

Sum neighbor pixels weighted by the kernel matrix. You can find a nice explanation with examples at GIMP's Convolution Matrix plugin

  • @param {array} kernel a matrix to weight the neighbors sum
  • @param {string} edgeHandling (optional) define how to sum pixels from outside the border
  • @param {function(Error, Jimp)} cb (optional) a callback for when complete
import jimp from 'jimp';

async function main() {
  const image = await jimp.read('test/image.png');

  // make me better
  image.convolution(weights);
}

main();

opaque

Set the alpha channel on every pixel to fully opaque

  • @param {function(Error, Jimp)} cb (optional) a callback for when complete
import jimp from 'jimp';

async function main() {
  const image = await jimp.read('test/image.png');

  image.opaque();
}

main();

pixelate

Pixelates the image or a region

  • @param {number} size the size of the pixels
  • @param {number} x (optional) the x position of the region to pixelate
  • @param {number} y (optional) the y position of the region to pixelate
  • @param {number} w (optional) the width of the region to pixelate
  • @param {number} h (optional) the height of the region to pixelate
  • @param {function(Error, Jimp)} cb (optional) a callback for when complete
import jimp from 'jimp';

async function main() {
  const image = await jimp.read('test/image.png');

  image.pixelate(10);
}

main();

convolute

Applies a convolution kernel to the image or a region

  • @param {array} kernel the convolution kernel
  • @param {number} x (optional) the x position of the region to apply convolution to
  • @param {number} y (optional) the y position of the region to apply convolution to
  • @param {number} w (optional) the width of the region to apply convolution to
  • @param {number} h (optional) the height of the region to apply convolution to
  • @param {function(Error, Jimp)} cb (optional) a callback for when complete
import jimp from 'jimp';

async function main() {
  const image = await jimp.read('test/image.png');

  // make me better
  image.pixelate(kernal);
}

main();

Current Tags

  • 1.1.5--canary.d9590e7.0                                ...           canary (2 months ago)
  • 1.6.0                                ...           latest (2 months ago)

243 Versions

  • 1.6.0                                ...           2 months ago
  • 1.5.0                                ...           2 months ago
  • 1.4.0                                ...           2 months ago
  • 1.3.0                                ...           2 months ago
  • 1.2.0                                ...           2 months ago
  • 1.1.5                                ...           2 months ago
  • 1.1.5--canary.d9590e7.0                                ...           2 months ago
  • 1.1.4                                ...           2 months ago
  • 1.1.4--canary.3197852.0                                ...           2 months ago
  • 1.1.3                                ...           2 months ago
  • 1.1.3--canary.34e8f3b.0                                ...           2 months ago
  • 1.1.2                                ...           2 months ago
  • 1.1.1                                ...           2 months ago
  • 1.1.1--canary.8356674.0                                ...           2 months ago
  • 1.1.0                                ...           2 months ago
  • 1.0.5                                ...           2 months ago
  • 1.0.4                                ...           2 months ago
  • 1.0.3                                ...           2 months ago
  • 1.0.2                                ...           2 months ago
  • 1.0.2--canary.4e85de0.0                                ...           2 months ago
  • 0.22.12                                ...           9 months ago
  • 0.22.11                                ...           9 months ago
  • 0.22.11--canary.c55989b.0                                ...           9 months ago
  • 0.22.10                                ...           a year ago
  • 0.22.9                                ...           a year ago
  • 0.22.8                                ...           2 years ago
  • 0.22.7                                ...           2 years ago
  • 0.22.6                                ...           2 years ago
  • 0.22.6--canary.1198.9324a88b87a1fc38b528af47ca707d97593dddaa.0                                ...           2 years ago
  • 0.22.5                                ...           2 years ago
  • 0.22.4                                ...           2 years ago
  • 0.22.4--canary.1187.30d10f964404705d383d7163b7d3f85baa2201b7.0                                ...           2 years ago
  • 0.22.3                                ...           2 years ago
  • 0.22.3--canary.1184.ff6583af74ba85d9555c36db2844886e269feb16.0                                ...           2 years ago
  • 0.22.2                                ...           2 years ago
  • 0.22.1                                ...           2 years ago
  • 0.22.1--canary.1173.30a931db5f6552c59e4c99f41fdb9e2b9ccf8291.0                                ...           2 years ago
  • 0.22.1--canary.1169.6db477d088d28aea43b31d9ca8b0eaf74dc511d1.0                                ...           2 years ago
  • 0.22.0                                ...           2 years ago
  • 0.21.4--canary.1163.d07ed6254d130e2995d24101e93427ec091016e6.0                                ...           2 years ago
  • 0.21.4--canary.1163.7b9287fff1036ae67190d5ea3a8dec9926373a63.0                                ...           2 years ago
  • 0.21.4--canary.1163.6a6ae39e83bd731ccd25120a160a75b32273f9bd.0                                ...           2 years ago
  • 0.21.4--canary.1163.a26f5b300ee88c2fadb9909dd390cb4380b32a42.0                                ...           2 years ago
  • 0.21.3                                ...           2 years ago
  • 0.21.2                                ...           2 years ago
  • 0.21.2--canary.1156.1f8a92bfc1cbc6b5f3ad2490d0ec86710c81f635.0                                ...           2 years ago
  • 0.21.2--canary.1156.ba9fec9d0c9109924b4a5acab31bcaef8159a610.0                                ...           2 years ago
  • 0.21.2--canary.1156.8b2cc45.0                                ...           2 years ago
  • 0.21.1                                ...           2 years ago
  • 0.21.1--canary.1153.3cc6d7b.0                                ...           2 years ago
  • 0.21.0                                ...           2 years ago
  • 0.21.0--canary.1149.a81f653.0                                ...           2 years ago
  • 0.21.0--canary.1149.3239903.0                                ...           2 years ago
  • 0.20.2                                ...           2 years ago
  • 0.20.1                                ...           2 years ago
  • 0.20.0                                ...           2 years ago
  • 0.19.0                                ...           2 years ago
  • 0.17.9--canary.1144.3455afd.0                                ...           2 years ago
  • 0.17.9--canary.1143.90575e6.0                                ...           2 years ago
  • 0.17.9--canary.fc042e5.0                                ...           2 years ago
  • 0.18.0                                ...           2 years ago
  • 0.17.9--canary.1141.cd4d455.0                                ...           2 years ago
  • 0.17.10                                ...           2 years ago
  • 0.17.9--canary.1140.e3ff49d.0                                ...           2 years ago
  • 0.17.9--canary.1140.4042b43.0                                ...           2 years ago
  • 0.17.9--canary.1140.831bc3c.0                                ...           2 years ago
  • 0.17.9                                ...           2 years ago
  • 0.17.8                                ...           2 years ago
  • 0.17.8--canary.1137.476d7bd.0                                ...           2 years ago
  • 0.17.7                                ...           2 years ago
  • 0.17.6                                ...           2 years ago
  • 0.17.6--canary.1137.5e459dc.0                                ...           2 years ago
  • 0.17.6--canary.cd893f3.0                                ...           2 years ago
  • 0.17.6--canary.1cb89cf.0                                ...           2 years ago
  • 0.17.5                                ...           2 years ago
  • 0.17.4                                ...           2 years ago
  • 0.17.3                                ...           2 years ago
  • 0.17.3--canary.1136.7f5f5d8.0                                ...           2 years ago
  • 0.17.2                                ...           2 years ago
  • 0.18.0--canary.1135.911ed04.0                                ...           2 years ago
  • 0.17.1                                ...           2 years ago
  • 0.17.1--canary.1134.e007a48.0                                ...           2 years ago
  • 0.17.1--canary.e22c14a.0                                ...           2 years ago
  • 0.18.0--canary.1133.54bf269.0                                ...           2 years ago
  • 0.17.0                                ...           2 years ago
  • 0.17.0--canary.1131.af3cb94.0                                ...           2 years ago
  • 0.16.13                                ...           2 years ago
  • 0.16.12                                ...           2 years ago
  • 0.16.11                                ...           2 years ago
  • 0.16.10                                ...           2 years ago
  • 0.16.9                                ...           2 years ago
  • 0.16.8                                ...           2 years ago
  • 0.16.7                                ...           2 years ago
  • 0.16.6                                ...           2 years ago
  • 0.16.5                                ...           2 years ago
  • 0.16.4                                ...           2 years ago
  • 0.16.3                                ...           2 years ago
  • 0.16.3-canary.993.1592.0                                ...           2 years ago
  • 0.16.3-canary.1045.1590.0                                ...           2 years ago
  • 0.16.3-canary.1082.1591.0                                ...           2 years ago
  • 0.16.3-canary.1040.1589.0                                ...           2 years ago
  • 0.16.3-canary.999.1588.0                                ...           2 years ago
  • 0.16.3-canary.1085.1581.0                                ...           2 years ago
  • 0.16.3-canary.1014.1579.0                                ...           2 years ago
  • 0.16.3-canary.1125.1580.0                                ...           2 years ago
  • 0.16.3-canary.1113.1404.0                                ...           2 years ago
  • 0.16.3-canary.1109.1388.0                                ...           2 years ago
  • 0.16.3-canary.1108.1382.0                                ...           2 years ago
  • 0.16.3-canary.1100.1371.0                                ...           2 years ago
  • 0.16.2                                ...           2 years ago
  • 0.16.2-canary.1087.1357.0                                ...           2 years ago
  • 0.16.2-canary.1094.1345.0                                ...           2 years ago
  • 0.16.2-canary.1093.1332.0                                ...           2 years ago
  • 0.16.2-canary.1086.1311.0                                ...           2 years ago
  • 0.16.2-canary.1084.1305.0                                ...           2 years ago
  • 0.16.2-canary.1082.1294.0                                ...           3 years ago
  • 0.16.2-canary.1080.1288.0                                ...           3 years ago
  • 0.16.2-canary.1073.1276.0                                ...           3 years ago
  • 0.16.2-canary.1070.1265.0                                ...           3 years ago
  • 0.16.2-canary.1052.1235.0                                ...           3 years ago
  • 0.16.2-canary.1051.1228.0                                ...           3 years ago
  • 0.16.2-canary.1045.1221.0                                ...           3 years ago
  • 0.16.2-canary.1016.1185.0                                ...           3 years ago
  • 0.16.2-canary.1008.1164.0                                ...           4 years ago
  • 0.16.2-canary.984.1126.0                                ...           4 years ago
  • 0.16.2-canary.969.1115.0                                ...           4 years ago
  • 0.16.2-canary.964.1101.0                                ...           4 years ago
  • 0.16.2-canary.956.1095.0                                ...           4 years ago
  • 0.16.2-canary.947.1077.0                                ...           4 years ago
  • 0.16.2-canary.938.1059.0                                ...           4 years ago
  • 0.16.2-canary.934.1053.0                                ...           4 years ago
  • 0.16.2-canary.919.1052.0                                ...           4 years ago
  • 0.16.1                                ...           4 years ago
  • 0.16.0                                ...           4 years ago
  • 0.15.1-canary.924.1021.0                                ...           4 years ago
  • 0.15.0                                ...           4 years ago
  • 0.14.1-canary.919.1005.0                                ...           4 years ago
  • 0.14.1-canary.911.993.0                                ...           4 years ago
  • 0.14.0                                ...           4 years ago
  • 0.14.0-canary.904.976.0                                ...           4 years ago
  • 0.13.0-canary.899.964.0                                ...           4 years ago
  • 0.13.0                                ...           4 years ago
  • 0.12.2-canary.899.952.0                                ...           4 years ago
  • 0.12.1                                ...           4 years ago
  • 0.12.1-canary.892.924.0                                ...           4 years ago
  • 0.12.0                                ...           4 years ago
  • 0.11.1-canary.891.908.0                                ...           4 years ago
  • 0.11.0                                ...           4 years ago
  • 0.10.5-canary.882.886.0                                ...           5 years ago
  • 0.10.4-canary.882.884.0                                ...           5 years ago
  • 0.10.4-canary.882.885.0                                ...           5 years ago
  • 0.10.3                                ...           5 years ago
  • 0.10.2                                ...           5 years ago
  • 0.10.2-canary.875.842.0                                ...           5 years ago
  • 0.10.1                                ...           5 years ago
  • 0.10.1-canary.870.821.0                                ...           5 years ago
  • 0.10.0                                ...           5 years ago
  • 0.9.9-canary.868.799.0                                ...           5 years ago
  • 0.9.9-canary.867.792.0                                ...           5 years ago
  • 0.9.8                                ...           5 years ago
  • 0.9.8-canary.866.767.0                                ...           5 years ago
  • 0.9.7                                ...           5 years ago
  • 0.9.7-canary.854.725.0                                ...           5 years ago
  • 0.9.6                                ...           5 years ago
  • 0.9.6-canary.860.700.0                                ...           5 years ago
  • 0.9.6-canary.857.681.0                                ...           5 years ago
  • 0.9.6-canary.858.667.0                                ...           5 years ago
  • 0.9.5                                ...           5 years ago
  • 0.9.4                                ...           5 years ago
  • 0.9.4-canary.845.627.0                                ...           5 years ago
  • 0.9.4-canary.841.620.0                                ...           5 years ago
  • 0.9.4-canary.838.613.0                                ...           5 years ago
  • 0.9.4-canary.832.606.0                                ...           5 years ago
  • 0.9.3-canary.825.599.0                                ...           5 years ago
  • 0.9.3                                ...           5 years ago
  • 0.9.3-canary.825.584.0                                ...           5 years ago
  • 0.9.2-canary.815.538.0                                ...           5 years ago
  • 0.9.1                                ...           5 years ago
  • 0.9.0                                ...           5 years ago
  • 0.8.6-canary.815.502.0                                ...           5 years ago
  • 0.8.6-canary.818.495.0                                ...           5 years ago
  • 0.8.6-canary.815.488.0                                ...           5 years ago
  • 0.8.6-canary.810.481.0                                ...           5 years ago
  • 0.8.5                                ...           5 years ago
  • 0.8.1-canary.791.466.0                                ...           5 years ago
  • 0.8.1-canary.789.460.0                                ...           5 years ago
  • 0.8.5-canary.799.447.0                                ...           5 years ago
  • 0.8.5-canary.1.b147e81.0                                ...           5 years ago
  • 0.8.5-canary.b147e81.0                                ...           5 years ago
  • 0.8.5-canary.753c2c9.0                                ...           5 years ago
  • 0.8.5-canary.800.426.0                                ...           5 years ago
  • 0.8.4                                ...           5 years ago
  • 0.8.4-canary.798.377.0                                ...           5 years ago
  • 0.8.3                                ...           5 years ago
  • 0.8.2-canary.792.360.0                                ...           5 years ago
  • 0.8.2-canary.792.353.0                                ...           5 years ago
  • 0.8.2-canary.792.349.0                                ...           5 years ago
  • 0.8.2-canary.792.339.0                                ...           5 years ago
  • 0.8.2-canary.792.332.0                                ...           5 years ago
  • 0.8.2                                ...           5 years ago
  • 0.8.2-canary.794.308.0                                ...           5 years ago
  • 0.8.1-canary.789.301.0                                ...           5 years ago
  • 0.8.2-canary.792.290.0                                ...           5 years ago
  • 0.8.2-canary.792.283.0                                ...           5 years ago
  • 0.8.1-canary.791.276.0                                ...           5 years ago
  • 0.8.1                                ...           5 years ago
  • 0.8.1-canary.786.262.0                                ...           5 years ago
  • 0.8.1-canary.786.242.0                                ...           5 years ago
  • 0.8.1-canary.786.232.0                                ...           5 years ago
  • 0.8.1-canary.786.223.0                                ...           5 years ago
  • 0.8.1-canary.786.217.0                                ...           5 years ago
  • 0.8.1-canary.786.211.0                                ...           5 years ago
  • 0.8.0                                ...           5 years ago
  • 0.7.1-canary.770.193.0                                ...           5 years ago
  • 0.7.0                                ...           5 years ago
  • 0.6.8                                ...           5 years ago
  • 0.6.8-canary.783.163.0                                ...           5 years ago
  • 0.6.7-canary.783.157.0                                ...           5 years ago
  • 0.6.7                                ...           5 years ago
  • 0.6.6                                ...           5 years ago
  • 0.6.5                                ...           5 years ago
  • 0.6.5-canary.784.124.0                                ...           5 years ago
  • 0.6.5-canary.784.118.0                                ...           5 years ago
  • 0.6.5-canary.eeb6481.0                                ...           5 years ago
  • 0.6.5-canary.4564f3c.0                                ...           5 years ago
  • 0.6.4                                ...           6 years ago
  • 0.6.2                                ...           6 years ago
  • 0.6.0                                ...           6 years ago
  • 0.5.5                                ...           6 years ago
  • 0.5.4                                ...           6 years ago
  • 0.5.3                                ...           6 years ago
  • 0.5.2                                ...           6 years ago
  • 0.5.1                                ...           6 years ago
  • 0.5.0                                ...           6 years ago
  • 0.4.0                                ...           6 years ago
  • 0.3.10                                ...           6 years ago
  • 0.3.9                                ...           6 years ago
  • 0.3.9-alpha.0                                ...           6 years ago
  • 0.3.8                                ...           6 years ago
  • 0.3.7                                ...           6 years ago
  • 0.3.6                                ...           6 years ago
  • 0.3.6-alpha.6                                ...           6 years ago
  • 0.3.6-alpha.5                                ...           6 years ago
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (3)

© 2010 - cnpmjs.org x YWFE | Home | YWFE