Skip to content

Commit

Permalink
Docs: ensure all functions include method signature #3777
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Aug 29, 2023
1 parent 9c7713e commit 67e927b
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/api-channel.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## removeAlpha
> removeAlpha() ⇒ <code>Sharp</code>
Remove alpha channel, if any. This is a no-op if the image does not have an alpha channel.

See also [flatten](/api-operation#flatten).
Expand All @@ -15,6 +17,8 @@ sharp('rgba.png')


## ensureAlpha
> ensureAlpha([alpha]) ⇒ <code>Sharp</code>
Ensure the output image has an alpha transparency channel.
If missing, the added alpha channel will have the specified
transparency level, defaulting to fully-opaque (1).
Expand Down Expand Up @@ -48,6 +52,8 @@ const rgba = await sharp(rgb)


## extractChannel
> extractChannel(channel) ⇒ <code>Sharp</code>
Extract a single channel from a multi-channel image.


Expand Down Expand Up @@ -78,6 +84,8 @@ const [red1, red2, ...] = await sharp(input)


## joinChannel
> joinChannel(images, options) ⇒ <code>Sharp</code>
Join one or more channels to the image.
The meaning of the added channels depends on the output colourspace, set with `toColourspace()`.
By default the output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
Expand All @@ -102,6 +110,8 @@ For raw pixel input, the `options` object should contain a `raw` attribute, whic


## bandbool
> bandbool(boolOp) ⇒ <code>Sharp</code>
Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image.


Expand Down
14 changes: 14 additions & 0 deletions docs/api-colour.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## tint
> tint(rgb) ⇒ <code>Sharp</code>
Tint the image using the provided chroma while preserving the image luminance.
An alpha channel may be present and will be unchanged by the operation.

Expand All @@ -21,6 +23,8 @@ const output = await sharp(input)


## greyscale
> greyscale([greyscale]) ⇒ <code>Sharp</code>
Convert to 8-bit greyscale; 256 shades of grey.
This is a linear operation. If the input image is in a non-linear colour space such as sRGB, use `gamma()` with `greyscale()` for the best results.
By default the output image will be web-friendly sRGB and contain three (identical) color channels.
Expand All @@ -41,6 +45,8 @@ const output = await sharp(input).greyscale().toBuffer();


## grayscale
> grayscale([grayscale]) ⇒ <code>Sharp</code>
Alternative spelling of `greyscale`.


Expand All @@ -52,6 +58,8 @@ Alternative spelling of `greyscale`.


## pipelineColourspace
> pipelineColourspace([colourspace]) ⇒ <code>Sharp</code>
Set the pipeline colourspace.

The input image will be converted to the provided colourspace at the start of the pipeline.
Expand Down Expand Up @@ -82,6 +90,8 @@ await sharp(input)


## pipelineColorspace
> pipelineColorspace([colorspace]) ⇒ <code>Sharp</code>
Alternative spelling of `pipelineColourspace`.


Expand All @@ -97,6 +107,8 @@ Alternative spelling of `pipelineColourspace`.


## toColourspace
> toColourspace([colourspace]) ⇒ <code>Sharp</code>
Set the output colourspace.
By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.

Expand All @@ -120,6 +132,8 @@ await sharp(input)


## toColorspace
> toColorspace([colorspace]) ⇒ <code>Sharp</code>
Alternative spelling of `toColourspace`.


Expand Down
2 changes: 2 additions & 0 deletions docs/api-composite.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## composite
> composite(images) ⇒ <code>Sharp</code>
Composite image(s) over the processed (resized, extracted etc.) image.

The images to composite must be the same size or smaller than the processed image.
Expand Down
6 changes: 6 additions & 0 deletions docs/api-constructor.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
## Sharp
> Sharp

**Emits**: <code>Sharp#event:info</code>, <code>Sharp#event:warning</code>
<a name="new_Sharp_new"></a>

### new
> new Sharp([input], [options])
Constructor factory to create an instance of `sharp`, to which further methods are chained.

JPEG, PNG, WebP, GIF, AVIF or TIFF format image data can be streamed out from this object.
Expand Down Expand Up @@ -159,6 +163,8 @@ await sharp({


## clone
> clone() ⇒ [<code>Sharp</code>](#Sharp)
Take a "snapshot" of the Sharp instance, returning a new instance.
Cloned instances inherit the input of their parent instance.
This allows multiple output Streams and therefore multiple processing pipelines to share a single input Stream.
Expand Down
4 changes: 4 additions & 0 deletions docs/api-input.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## metadata
> metadata([callback]) ⇒ <code>Promise.&lt;Object&gt;</code> \| <code>Sharp</code>
Fast access to (uncached) image metadata without decoding any compressed pixel data.

This is read from the header of the input image.
Expand Down Expand Up @@ -81,6 +83,8 @@ function getNormalSize({ width, height, orientation }) {


## stats
> stats([callback]) ⇒ <code>Promise.&lt;Object&gt;</code>
Access to pixel-derived image statistics for every channel in the image.
A `Promise` is returned when `callback` is not provided.

Expand Down
40 changes: 40 additions & 0 deletions docs/api-operation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## rotate
> rotate([angle], [options]) ⇒ <code>Sharp</code>
Rotate the output image by either an explicit angle
or auto-orient based on the EXIF `Orientation` tag.

Expand Down Expand Up @@ -57,6 +59,8 @@ const resizeThenRotate = await sharp(input)


## flip
> flip([flip]) ⇒ <code>Sharp</code>
Mirror the image vertically (up-down) about the x-axis.
This always occurs before rotation, if any.

Expand All @@ -75,6 +79,8 @@ const output = await sharp(input).flip().toBuffer();


## flop
> flop([flop]) ⇒ <code>Sharp</code>
Mirror the image horizontally (left-right) about the y-axis.
This always occurs before rotation, if any.

Expand All @@ -91,6 +97,8 @@ const output = await sharp(input).flop().toBuffer();


## affine
> affine(matrix, [options]) ⇒ <code>Sharp</code>
Perform an affine transform on an image. This operation will always occur after resizing, extraction and rotation, if any.

You must provide an array of length 4 or a 2x2 affine transformation matrix.
Expand Down Expand Up @@ -142,6 +150,8 @@ inputStream


## sharpen
> sharpen([options], [flat], [jagged]) ⇒ <code>Sharp</code>
Sharpen the image.

When used without parameters, performs a fast, mild sharpen of the output image.
Expand Down Expand Up @@ -193,6 +203,8 @@ const data = await sharp(input)


## median
> median([size]) ⇒ <code>Sharp</code>
Apply median filter.
When used without parameters the default window is 3x3.

Expand All @@ -217,6 +229,8 @@ const output = await sharp(input).median(5).toBuffer();


## blur
> blur([sigma]) ⇒ <code>Sharp</code>
Blur the image.

When used without parameters, performs a fast 3x3 box blur (equivalent to a box linear filter).
Expand Down Expand Up @@ -248,6 +262,8 @@ const gaussianBlurred = await sharp(input)


## flatten
> flatten([options]) ⇒ <code>Sharp</code>
Merge alpha transparency channel, if any, with a background, then remove the alpha channel.

See also [removeAlpha](/api-channel#removealpha).
Expand All @@ -268,6 +284,8 @@ await sharp(rgbaInput)


## unflatten
> unflatten()
Ensure the image has an alpha channel
with all white pixel values made fully transparent.

Expand All @@ -293,6 +311,8 @@ await sharp(rgbInput)


## gamma
> gamma([gamma], [gammaOut]) ⇒ <code>Sharp</code>
Apply a gamma correction by reducing the encoding (darken) pre-resize at a factor of `1/gamma`
then increasing the encoding (brighten) post-resize at a factor of `gamma`.
This can improve the perceived brightness of a resized image in non-linear colour spaces.
Expand All @@ -315,6 +335,8 @@ Supply a second argument to use a different output gamma value, otherwise the fi


## negate
> negate([options]) ⇒ <code>Sharp</code>
Produce the "negative" of the image.


Expand All @@ -339,6 +361,8 @@ const output = await sharp(input)


## normalise
> normalise([options]) ⇒ <code>Sharp</code>
Enhance output image contrast by stretching its luminance to cover a full dynamic range.

Uses a histogram-based approach, taking a default range of 1% to 99% to reduce sensitivity to noise at the extremes.
Expand Down Expand Up @@ -369,6 +393,8 @@ const output = await sharp(input)


## normalize
> normalize([options]) ⇒ <code>Sharp</code>
Alternative spelling of normalise.


Expand All @@ -388,6 +414,8 @@ const output = await sharp(input)


## clahe
> clahe(options) ⇒ <code>Sharp</code>
Perform contrast limiting adaptive histogram equalization
[CLAHE](https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#Contrast_Limited_AHE).

Expand Down Expand Up @@ -419,6 +447,8 @@ const output = await sharp(input)


## convolve
> convolve(kernel) ⇒ <code>Sharp</code>
Convolve the image with the specified kernel.


Expand Down Expand Up @@ -453,6 +483,8 @@ sharp(input)


## threshold
> threshold([threshold], [options]) ⇒ <code>Sharp</code>
Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0.


Expand All @@ -471,6 +503,8 @@ Any pixel value greater than or equal to the threshold value will be set to 255,


## boolean
> boolean(operand, operator, [options]) ⇒ <code>Sharp</code>
Perform a bitwise boolean operation with operand image.

This operation creates an output image where each pixel is the result of
Expand All @@ -495,6 +529,8 @@ the selected bitwise boolean `operation` between the corresponding pixels of the


## linear
> linear([a], [b]) ⇒ <code>Sharp</code>
Apply the linear formula `a` * input + `b` to the image to adjust image levels.

When a single number is provided, it will be used for all image channels.
Expand Down Expand Up @@ -529,6 +565,8 @@ await sharp(rgbInput)


## recomb
> recomb(inputMatrix) ⇒ <code>Sharp</code>
Recombine the image with the specified matrix.


Expand Down Expand Up @@ -559,6 +597,8 @@ sharp(input)


## modulate
> modulate([options]) ⇒ <code>Sharp</code>
Transforms the image using brightness, saturation, hue rotation, and lightness.
Brightness and lightness both operate on luminance, with the difference being that
brightness is multiplicative whereas lightness is additive.
Expand Down
Loading

0 comments on commit 67e927b

Please sign in to comment.