mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Docs: changelog and credit for #2762
This commit is contained in:
@@ -727,31 +727,35 @@ function heif (options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Force output to be raw, uncompressed, 8-bit unsigned integer (unit8) pixel data.
|
||||
* Force output to be raw, uncompressed pixel data.
|
||||
* Pixel ordering is left-to-right, top-to-bottom, without padding.
|
||||
* Channel ordering will be RGB or RGBA for non-greyscale colourspaces.
|
||||
*
|
||||
* @example
|
||||
* // Extract raw RGB pixel data from JPEG input
|
||||
* // Extract raw, unsigned 8-bit RGB pixel data from JPEG input
|
||||
* const { data, info } = await sharp('input.jpg')
|
||||
* .raw()
|
||||
* .toBuffer({ resolveWithObject: true });
|
||||
*
|
||||
* @example
|
||||
* // Extract alpha channel as raw pixel data from PNG input
|
||||
* // Extract alpha channel as raw, unsigned 16-bit pixel data from PNG input
|
||||
* const data = await sharp('input.png')
|
||||
* .ensureAlpha()
|
||||
* .extractChannel(3)
|
||||
* .toColourspace('b-w')
|
||||
* .raw()
|
||||
* .raw({ depth: 'ushort' })
|
||||
* .toBuffer();
|
||||
*
|
||||
* @returns {Sharp}
|
||||
* @param {Object} [options] - output options
|
||||
* @param {string} [options.depth='uchar'] - bit depth, one of: char, uchar (default), short, ushort, int, uint, float, complex, double, dpcomplex
|
||||
* @throws {Error} Invalid options
|
||||
*/
|
||||
function raw (options) {
|
||||
if (is.object(options)) {
|
||||
if (is.defined(options.depth)) {
|
||||
if (is.string(options.depth) && is.inArray(options.depth, ['char', 'uchar', 'short', 'ushort', 'int', 'uint', 'float', 'complex', 'double', 'dpcomplex'])) {
|
||||
if (is.string(options.depth) && is.inArray(options.depth,
|
||||
['char', 'uchar', 'short', 'ushort', 'int', 'uint', 'float', 'complex', 'double', 'dpcomplex']
|
||||
)) {
|
||||
this.options.rawDepth = options.depth;
|
||||
} else {
|
||||
throw is.invalidParameterError('depth', 'one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex', options.depth);
|
||||
|
||||
Reference in New Issue
Block a user