diff --git a/docs/api-colour.md b/docs/api-colour.md
index b8fe1f469..a16eb886a 100644
--- a/docs/api-colour.md
+++ b/docs/api-colour.md
@@ -27,9 +27,9 @@ const output = await sharp(input)
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.
+By default the output image will be web-friendly sRGB and contain three (identical) colour channels.
This may be overridden by other sharp operations such as `toColourspace('b-w')`,
-which will produce an output image containing one color channel.
+which will produce an output image containing one colour channel.
An alpha channel may be present, and will be unchanged by the operation.
diff --git a/docs/api-constructor.md b/docs/api-constructor.md
index 2d31c86b0..32a79a011 100644
--- a/docs/api-constructor.md
+++ b/docs/api-constructor.md
@@ -40,7 +40,7 @@ where the overall height is the `pageHeight` multiplied by the number of `pages`
| [options.page] | number
| 0
| Page number to start extracting from for multi-page input (GIF, WebP, TIFF), zero based. |
| [options.subifd] | number
| -1
| subIFD (Sub Image File Directory) to extract for OME-TIFF, defaults to main image. |
| [options.level] | number
| 0
| level to extract from a multi-level input (OpenSlide), zero based. |
-| [options.pdfBackground] | string
\| Object
| | Background color to use when PDF is partially transparent. Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. Requires the use of a globally-installed libvips compiled with support for PDFium, poppler-glib, ImageMagick, or GraphicsMagick. |
+| [options.pdfBackground] | string
\| Object
| | Background colour to use when PDF is partially transparent. Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. Requires the use of a globally-installed libvips compiled with support for PDFium, Poppler, ImageMagick or GraphicsMagick. |
| [options.animated] | boolean
| false
| Set to `true` to read all frames/pages of an animated image (GIF, WebP, TIFF), equivalent of setting `pages` to `-1`. |
| [options.raw] | Object
| | describes raw pixel input image data. See `raw()` for pixel ordering. |
| [options.raw.width] | number
| | integral number of pixels wide. |
diff --git a/docs/api-operation.md b/docs/api-operation.md
index 86f07e582..d38e209ff 100644
--- a/docs/api-operation.md
+++ b/docs/api-operation.md
@@ -104,7 +104,7 @@ const output = await sharp(input).flop().toBuffer();
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.
-By default, new pixels are filled with a black background. You can provide a background color with the `background` option.
+By default, new pixels are filled with a black background. You can provide a background colour with the `background` option.
A particular interpolator may also be specified. Set the `interpolator` option to an attribute of the `sharp.interpolators` Object e.g. `sharp.interpolators.nohalo`.
In the case of a 2x2 matrix, the transform is:
diff --git a/lib/colour.js b/lib/colour.js
index 305f72531..d8a4de4f9 100644
--- a/lib/colour.js
+++ b/lib/colour.js
@@ -39,9 +39,9 @@ function tint (tint) {
/**
* 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.
+ * By default the output image will be web-friendly sRGB and contain three (identical) colour channels.
* This may be overridden by other sharp operations such as `toColourspace('b-w')`,
- * which will produce an output image containing one color channel.
+ * which will produce an output image containing one colour channel.
* An alpha channel may be present, and will be unchanged by the operation.
*
* @example
diff --git a/lib/constructor.js b/lib/constructor.js
index 73e90a676..0ff85c667 100644
--- a/lib/constructor.js
+++ b/lib/constructor.js
@@ -139,7 +139,7 @@ const debuglog = util.debuglog('sharp');
* @param {number} [options.page=0] - Page number to start extracting from for multi-page input (GIF, WebP, TIFF), zero based.
* @param {number} [options.subifd=-1] - subIFD (Sub Image File Directory) to extract for OME-TIFF, defaults to main image.
* @param {number} [options.level=0] - level to extract from a multi-level input (OpenSlide), zero based.
- * @param {string|Object} [options.pdfBackground] - Background color to use when PDF is partially transparent. Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. Requires the use of a globally-installed libvips compiled with support for PDFium, poppler-glib, ImageMagick, or GraphicsMagick.
+ * @param {string|Object} [options.pdfBackground] - Background colour to use when PDF is partially transparent. Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. Requires the use of a globally-installed libvips compiled with support for PDFium, Poppler, ImageMagick or GraphicsMagick.
* @param {boolean} [options.animated=false] - Set to `true` to read all frames/pages of an animated image (GIF, WebP, TIFF), equivalent of setting `pages` to `-1`.
* @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.
* @param {number} [options.raw.width] - integral number of pixels wide.
diff --git a/lib/index.d.ts b/lib/index.d.ts
index 7411bc238..194561ea9 100644
--- a/lib/index.d.ts
+++ b/lib/index.d.ts
@@ -244,14 +244,14 @@ declare namespace sharp {
* @param tint Parsed by the color module.
* @returns A sharp instance that can be used to chain operations
*/
- tint(tint: Color): Sharp;
+ tint(tint: Colour | Color): Sharp;
/**
* 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.
- * This may be overridden by other sharp operations such as toColourspace('b-w'), which will produce an output image containing one color channel.
+ * By default the output image will be web-friendly sRGB and contain three (identical) colour channels.
+ * This may be overridden by other sharp operations such as toColourspace('b-w'), which will produce an output image containing one colour channel.
* An alpha channel may be present, and will be unchanged by the operation.
* @param greyscale true to enable and false to disable (defaults to true)
* @returns A sharp instance that can be used to chain operations
@@ -401,7 +401,7 @@ declare namespace sharp {
/**
* 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.
- * By default, new pixels are filled with a black background. You can provide a background color with the `background` option.
+ * By default, new pixels are filled with a black background. You can provide a background colour with the `background` option.
* A particular interpolator may also be specified. Set the `interpolator` option to an attribute of the `sharp.interpolators` Object e.g. `sharp.interpolators.nohalo`.
*
* In the case of a 2x2 matrix, the transform is:
@@ -935,8 +935,8 @@ declare namespace sharp {
subifd?: number | undefined;
/** Level to extract from a multi-level input (OpenSlide), zero based. (optional, default 0) */
level?: number | undefined;
- /** Background color to use when PDF is partially transparent. Requires the use of a globally-installed libvips compiled with support for PDFium, poppler-glib, ImageMagick, or GraphicsMagick. */
- pdfBackground?: Color | undefined;
+ /** Background colour to use when PDF is partially transparent. Requires the use of a globally-installed libvips compiled with support for PDFium, Poppler, ImageMagick or GraphicsMagick. */
+ pdfBackground?: Colour | Color | undefined;
/** Set to `true` to read all frames/pages of an animated image (equivalent of setting `pages` to `-1`). (optional, default false) */
animated?: boolean | undefined;
/** Describes raw pixel input image data. See raw() for pixel ordering. */
@@ -987,7 +987,7 @@ declare namespace sharp {
/** Number of bands e.g. 3 for RGB, 4 for RGBA */
channels: Channels;
/** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */
- background: Color;
+ background: Colour | Color;
/** Describes a noise to be created. */
noise?: Noise | undefined;
}
@@ -1341,7 +1341,7 @@ declare namespace sharp {
interface RotateOptions {
/** parsed by the color module to extract values for red, green, blue and alpha. (optional, default "#000000") */
- background?: Color | undefined;
+ background?: Colour | Color | undefined;
}
type Precision = 'integer' | 'float' | 'approximate';
@@ -1357,7 +1357,7 @@ declare namespace sharp {
interface FlattenOptions {
/** background colour, parsed by the color module, defaults to black. (optional, default {r:0,g:0,b:0}) */
- background?: Color | undefined;
+ background?: Colour | Color | undefined;
}
interface NegateOptions {
@@ -1382,7 +1382,7 @@ declare namespace sharp {
/** Position, gravity or strategy to use when fit is cover or contain. (optional, default 'centre') */
position?: number | string | undefined;
/** Background colour when using a fit of contain, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
- background?: Color | undefined;
+ background?: Colour | Color | undefined;
/** The kernel to use for image reduction. (optional, default 'lanczos3') */
kernel?: keyof KernelEnum | undefined;
/** Do not enlarge if the width or height are already less than the specified dimensions, equivalent to GraphicsMagick's > geometry option. (optional, default false) */
@@ -1425,14 +1425,14 @@ declare namespace sharp {
/** single pixel count to right edge (optional, default 0) */
right?: number | undefined;
/** background colour, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
- background?: Color | undefined;
+ background?: Colour | Color | undefined;
/** how the extension is done, one of: "background", "copy", "repeat", "mirror" (optional, default `'background'`) */
extendWith?: ExtendWith | undefined;
}
interface TrimOptions {
/** Background colour, parsed by the color module, defaults to that of the top-left pixel. (optional) */
- background?: Color | undefined;
+ background?: Colour | Color | undefined;
/** Allowed difference from the above colour, a positive number. (optional, default 10) */
threshold?: number | undefined;
/** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
@@ -1453,7 +1453,8 @@ declare namespace sharp {
alpha?: number | undefined;
}
- type Color = string | RGBA;
+ type Colour = string | RGBA;
+ type Color = Colour;
interface Kernel {
/** width of the kernel in pixels. */
diff --git a/lib/input.js b/lib/input.js
index e2a494cb3..abb10e53a 100644
--- a/lib/input.js
+++ b/lib/input.js
@@ -8,7 +8,7 @@ const is = require('./is');
const sharp = require('./sharp');
/**
- * Justication alignment
+ * Justification alignment
* @member
* @private
*/
@@ -26,7 +26,7 @@ const align = {
function _inputOptionsFromObject (obj) {
const { raw, density, limitInputPixels, ignoreIcc, unlimited, sequentialRead, failOn, failOnError, animated, page, pages, subifd, pdfBackground } = obj;
return [raw, density, limitInputPixels, ignoreIcc, unlimited, sequentialRead, failOn, failOnError, animated, page, pages, subifd, pdfBackground].some(is.defined)
- ? { raw, density, limitInputPixels, ignoreIcc, unlimited, sequentialRead, failOn, failOnError, animated, page, pages, subifd }
+ ? { raw, density, limitInputPixels, ignoreIcc, unlimited, sequentialRead, failOn, failOnError, animated, page, pages, subifd, pdfBackground }
: undefined;
}
@@ -222,7 +222,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
throw is.invalidParameterError('subifd', 'integer between -1 and 100000', inputOptions.subifd);
}
}
- // PDF background color
+ // PDF background colour
if (is.defined(inputOptions.pdfBackground)) {
this._setBackgroundColourOption('pdfBackground', inputOptions.pdfBackground);
}
diff --git a/lib/operation.js b/lib/operation.js
index 6135f37cb..538286491 100644
--- a/lib/operation.js
+++ b/lib/operation.js
@@ -128,7 +128,7 @@ function flop (flop) {
* 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.
- * By default, new pixels are filled with a black background. You can provide a background color with the `background` option.
+ * By default, new pixels are filled with a black background. You can provide a background colour with the `background` option.
* A particular interpolator may also be specified. Set the `interpolator` option to an attribute of the `sharp.interpolators` Object e.g. `sharp.interpolators.nohalo`.
*
* In the case of a 2x2 matrix, the transform is:
diff --git a/test/types/sharp.test-d.ts b/test/types/sharp.test-d.ts
index 80c9f2abc..5a502e374 100644
--- a/test/types/sharp.test-d.ts
+++ b/test/types/sharp.test-d.ts
@@ -713,4 +713,9 @@ sharp(input).composite([
density: 72,
failOn: "truncated"
}
-])
\ No newline at end of file
+])
+
+const colour: sharp.Colour = '#fff';
+const color: sharp.Color = '#fff';
+sharp({ pdfBackground: colour });
+sharp({ pdfBackground: color });