Docs: clarify that metadata is based on input, not output

This commit is contained in:
Lovell Fuller 2021-12-12 20:38:23 +00:00
parent dd6583044b
commit 2b8e4d20de
3 changed files with 18 additions and 3 deletions

View File

@ -2,7 +2,11 @@
## metadata ## metadata
Fast access to (uncached) image metadata without decoding any compressed image data. Fast access to (uncached) image metadata without decoding any compressed pixel data.
This is taken from the header of the input image.
It does not include operations, such as resize, to be applied to the output image.
A `Promise` is returned when `callback` is not provided. A `Promise` is returned when `callback` is not provided.
* `format`: Name of decoder used to decompress image data e.g. `jpeg`, `png`, `webp`, `gif`, `svg` * `format`: Name of decoder used to decompress image data e.g. `jpeg`, `png`, `webp`, `gif`, `svg`
@ -39,6 +43,10 @@ A `Promise` is returned when `callback` is not provided.
### Examples ### Examples
```javascript
const metadata = await sharp(input).metadata();
```
```javascript ```javascript
const image = sharp(inputJpg); const image = sharp(inputJpg);
image image

File diff suppressed because one or more lines are too long

View File

@ -290,7 +290,11 @@ function _isStreamInput () {
} }
/** /**
* Fast access to (uncached) image metadata without decoding any compressed image data. * Fast access to (uncached) image metadata without decoding any compressed pixel data.
*
* This is taken from the header of the input image.
* It does not include operations, such as resize, to be applied to the output image.
*
* A `Promise` is returned when `callback` is not provided. * A `Promise` is returned when `callback` is not provided.
* *
* - `format`: Name of decoder used to decompress image data e.g. `jpeg`, `png`, `webp`, `gif`, `svg` * - `format`: Name of decoder used to decompress image data e.g. `jpeg`, `png`, `webp`, `gif`, `svg`
@ -322,6 +326,9 @@ function _isStreamInput () {
* - `tifftagPhotoshop`: Buffer containing raw TIFFTAG_PHOTOSHOP data, if present * - `tifftagPhotoshop`: Buffer containing raw TIFFTAG_PHOTOSHOP data, if present
* *
* @example * @example
* const metadata = await sharp(input).metadata();
*
* @example
* const image = sharp(inputJpg); * const image = sharp(inputJpg);
* image * image
* .metadata() * .metadata()