diff --git a/lib/input.js b/lib/input.js index 7e5effcfa..1469bbae2 100644 --- a/lib/input.js +++ b/lib/input.js @@ -299,8 +299,8 @@ function _isStreamInput () { * * - `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 - * - `width`: Number of pixels wide (EXIF orientation is not taken into consideration) - * - `height`: Number of pixels high (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, see example below) * - `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://libvips.github.io/libvips/API/current/VipsImage.html#VipsInterpretation) * - `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK * - `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...](https://libvips.github.io/libvips/API/current/VipsImage.html#VipsBandFormat) @@ -343,6 +343,17 @@ function _isStreamInput () { * // data contains a WebP image half the width and height of the original JPEG * }); * + * @example + * // 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 }; + * } + * * @param {Function} [callback] - called with the arguments `(err, metadata)` * @returns {Promise|Sharp} */