mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Changelog and doc refresh for #915
This commit is contained in:
parent
d6aee8e5ba
commit
1d7a0ea99e
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- [clone](#clone)
|
- [clone](#clone)
|
||||||
- [metadata](#metadata)
|
- [metadata](#metadata)
|
||||||
|
- [stats](#stats)
|
||||||
- [limitInputPixels](#limitinputpixels)
|
- [limitInputPixels](#limitinputpixels)
|
||||||
- [sequentialRead](#sequentialread)
|
- [sequentialRead](#sequentialread)
|
||||||
|
|
||||||
@ -69,10 +70,10 @@ Returns **([Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Ref
|
|||||||
|
|
||||||
## stats
|
## stats
|
||||||
|
|
||||||
Access to pixel-derived image statistics for every channel in the image
|
Access to pixel-derived image statistics for every channel in the image.
|
||||||
A Promises/A+ promise is returned when `callback` is not provided.
|
A Promise is returned when `callback` is not provided.
|
||||||
|
|
||||||
- `channels`: Array of channel statistics for each channel in the image. Each channel statistic contains
|
- `channels`: Array of channel statistics for each channel in the image. Each channel statistic contains
|
||||||
- `min` (minimum value in the channel)
|
- `min` (minimum value in the channel)
|
||||||
- `max` (maximum value in the channel)
|
- `max` (maximum value in the channel)
|
||||||
- `sum` (sum of all values in a channel)
|
- `sum` (sum of all values in a channel)
|
||||||
@ -87,7 +88,7 @@ A Promises/A+ promise is returned when `callback` is not provided.
|
|||||||
|
|
||||||
**Parameters**
|
**Parameters**
|
||||||
|
|
||||||
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)?** called with the arguments `(err, metadata)`
|
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)?** called with the arguments `(err, stats)`
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
@ -96,12 +97,11 @@ const image = sharp(inputJpg);
|
|||||||
image
|
image
|
||||||
.stats()
|
.stats()
|
||||||
.then(function(stats) {
|
.then(function(stats) {
|
||||||
// stats contains the channel-wise statistics array and the isOpaque value
|
// stats contains the channel-wise statistics array and the isOpaque value
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns **([Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)> | Sharp)**
|
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>**
|
||||||
|
|
||||||
|
|
||||||
## limitInputPixels
|
## limitInputPixels
|
||||||
|
|
||||||
|
@ -14,6 +14,10 @@ Requires libvips v8.6.0.
|
|||||||
[#872](https://github.com/lovell/sharp/issues/872)
|
[#872](https://github.com/lovell/sharp/issues/872)
|
||||||
[@wmertens](https://github.com/wmertens)
|
[@wmertens](https://github.com/wmertens)
|
||||||
|
|
||||||
|
* Add stats feature for pixel-derived image statistics.
|
||||||
|
[#915](https://github.com/lovell/sharp/pull/915)
|
||||||
|
[@rnanwani](https://github.com/rnanwani)
|
||||||
|
|
||||||
* Add failOnError option to fail-fast on bad input image data.
|
* Add failOnError option to fail-fast on bad input image data.
|
||||||
[#976](https://github.com/lovell/sharp/pull/976)
|
[#976](https://github.com/lovell/sharp/pull/976)
|
||||||
[@mceachen](https://github.com/mceachen)
|
[@mceachen](https://github.com/mceachen)
|
||||||
|
31
lib/input.js
31
lib/input.js
@ -239,20 +239,20 @@ function metadata (callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to pixel-derived image statistics for every channel in the image
|
* Access to pixel-derived image statistics for every channel in the image.
|
||||||
* A Promise/A+ promise is returned when `callback` is not provided.
|
* A Promise is returned when `callback` is not provided.
|
||||||
*
|
*
|
||||||
* - `channels`: Array of channel statistics for each channel in the image. Each channel statistic contains
|
* - `channels`: Array of channel statistics for each channel in the image. Each channel statistic contains
|
||||||
* - `min` (minimum value in the channel)
|
* - `min` (minimum value in the channel)
|
||||||
* - `max` (maximum value in the channel)
|
* - `max` (maximum value in the channel)
|
||||||
* - `sum` (sum of all values in a channel)
|
* - `sum` (sum of all values in a channel)
|
||||||
* - `squaresSum` (sum of squared values in a channel)
|
* - `squaresSum` (sum of squared values in a channel)
|
||||||
* - `mean` (mean of the values in a channel)
|
* - `mean` (mean of the values in a channel)
|
||||||
* - `stdev` (standard deviation for the values in a channel)
|
* - `stdev` (standard deviation for the values in a channel)
|
||||||
* - `minX` (x-coordinate of one of the pixel where the minimum lies)
|
* - `minX` (x-coordinate of one of the pixel where the minimum lies)
|
||||||
* - `minY` (y-coordinate of one of the pixel where the minimum lies)
|
* - `minY` (y-coordinate of one of the pixel where the minimum lies)
|
||||||
* - `maxX` (x-coordinate of one of the pixel where the maximum lies)
|
* - `maxX` (x-coordinate of one of the pixel where the maximum lies)
|
||||||
* - `maxY` (y-coordinate of one of the pixel where the maximum lies)
|
* - `maxY` (y-coordinate of one of the pixel where the maximum lies)
|
||||||
* - `isOpaque`: Value to identify if the image is opaque or transparent, based on the presence and use of alpha channel
|
* - `isOpaque`: Value to identify if the image is opaque or transparent, based on the presence and use of alpha channel
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
@ -261,11 +261,10 @@ function metadata (callback) {
|
|||||||
* .stats()
|
* .stats()
|
||||||
* .then(function(stats) {
|
* .then(function(stats) {
|
||||||
* // stats contains the channel-wise statistics array and the isOpaque value
|
* // stats contains the channel-wise statistics array and the isOpaque value
|
||||||
* })
|
* });
|
||||||
*
|
|
||||||
*
|
*
|
||||||
* @param {Function} [callback] - called with the arguments `(err, stats)`
|
* @param {Function} [callback] - called with the arguments `(err, stats)`
|
||||||
* @returns {Promise<Object>|Sharp}
|
* @returns {Promise<Object>}
|
||||||
*/
|
*/
|
||||||
function stats (callback) {
|
function stats (callback) {
|
||||||
const that = this;
|
const that = this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user