mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Docs: refresh for metadata example #3127
This commit is contained in:
parent
4ac65054bc
commit
1de49f3ed8
@ -11,8 +11,8 @@ 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`
|
||||||
* `size`: Total size of image in bytes, for Stream and Buffer input only
|
* `size`: Total size of image in bytes, for Stream and Buffer input only
|
||||||
* `width`: Number of pixels wide (EXIF orientation is not taken into consideration)
|
* `width`: Number of pixels wide (EXIF orientation is not taken into consideration, see example below)
|
||||||
* `height`: Number of pixels high (EXIF orientation is not taken into consideration)
|
* `height`: Number of pixels high (EXIF orientation is not taken into consideration, see example below)
|
||||||
* `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...][1]
|
* `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...][1]
|
||||||
* `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK
|
* `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK
|
||||||
* `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...][2]
|
* `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...][2]
|
||||||
@ -63,6 +63,18 @@ image
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Based on EXIF rotation metadata, get the right-side-up width and height:
|
||||||
|
|
||||||
|
const size = getNormalSize(await sharp(input).metadata());
|
||||||
|
|
||||||
|
function getNormalSize({ width, height, orientation }) {
|
||||||
|
return orientation || 0 >= 5
|
||||||
|
? { width: height, height: width }
|
||||||
|
: { width, height };
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Returns **([Promise][5]<[Object][6]> | Sharp)**
|
Returns **([Promise][5]<[Object][6]> | Sharp)**
|
||||||
|
|
||||||
## stats
|
## stats
|
||||||
|
Loading…
x
Reference in New Issue
Block a user