Add most dominant colour to image stats #640

This commit is contained in:
Lovell Fuller
2020-07-15 19:58:54 +01:00
parent dcc42f8514
commit c42de19d2a
10 changed files with 130 additions and 36 deletions

View File

@@ -300,6 +300,7 @@ function metadata (callback) {
* - `isOpaque`: Is the image fully opaque? Will be `true` if the image has no alpha channel or if every pixel is fully opaque.
* - `entropy`: Histogram-based estimation of greyscale entropy, discarding alpha channel if any (experimental)
* - `sharpness`: Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any (experimental)
* - `dominant`: Object containing most dominant sRGB colour based on a 4096-bin 3D histogram (experimental)
*
* @example
* const image = sharp(inputJpg);
@@ -310,7 +311,8 @@ function metadata (callback) {
* });
*
* @example
* const { entropy, sharpness } = await sharp(input).stats();
* const { entropy, sharpness, dominant } = await sharp(input).stats();
* const { r, g, b } = dominant;
*
* @param {Function} [callback] - called with the arguments `(err, stats)`
* @returns {Promise<Object>}