1.0.2 • Published 9 years ago
is-colorful v1.0.2
is-colorful
Tells whether given image is colorful (or whether it is not monochromatic).
Here's how to currently works:
- Resizing image to achieve maximum dimension size, for faster processing
- Iterating through all pixels in resized image
- Converting them to HSL representation
- Selecting pixels with lightness in (minLightness..maxLightness) range and saturation > minSaturation
- Telling whether difference between minimum and maximum hue of selected pixels is greather than threshold
CLI Usage
Usage
  $ is-colorful <filename>
Options
  --resize          Area side in pixels to fit image to if it's larger (default: 400)
  --min-lightness   Minimum lightness of pixel to consider it (default: 30)
  --max-lightness   Maximum lightness of pixel to consider it (default: 70)
  --min-saturation  Maximum saturation of pixel to consider it (default: 70)
  --threshold       Minimum hue difference in considered pixels (deafult: 90)
Return code:
  - 0 if image is colorul
  - 1 on command failure
  - 2 if image is not colorful
Examples
  $ is-colorful pale-face.jpg --min-saturation 40Programmatic usage
isColorful(path, options)
Options are the same like in CLI, but camel cased.
import isColorful from 'is-colorful'
isColorful('pale-face.jpg', { minSaturation: 40 }).then((colorful) => {
  if (colorful) {
    console.log('Image is colorful!')
  }
})License
MIT
1.0.2
9 years ago