From 3f4398457f997b91d07ac22313a3f439898dfbbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Mich=C3=A1lek?= <1854431+Goues@users.noreply.github.com> Date: Mon, 25 Mar 2019 08:45:46 +0100 Subject: [PATCH] Change docs for `composite` to reflect how `create` works (#1623) --- docs/api-composite.md | 18 +++++++++--------- lib/composite.js | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/api-composite.md b/docs/api-composite.md index 05a83201..83490cc7 100644 --- a/docs/api-composite.md +++ b/docs/api-composite.md @@ -20,22 +20,22 @@ and [https://www.cairographics.org/operators/][2] ### Parameters - `images` **[Array][3]<[Object][4]>** Ordered list of images to composite - - `images[].input` **([Buffer][5] \| [String][6])?** Buffer containing image data or String containing the path to an image file. + - `images[].input` **([Buffer][5] \| [String][6])?** Buffer containing image data, String containing the path to an image file, or Create object (see bellow) + - `images[].input.create` **[Object][4]?** describes a blank overlay to be created. + - `images[].input.create.width` **[Number][7]?** + - `images[].input.create.height` **[Number][7]?** + - `images[].input.create.channels` **[Number][7]?** 3-4 + - `images[].input.create.background` **([String][6] \| [Object][4])?** parsed by the [color][8] module to extract values for red, green, blue and alpha. - `images[].blend` **[String][6]** how to blend this image with the image below. (optional, default `'over'`) - `images[].gravity` **[String][6]** gravity at which to place the overlay. (optional, default `'centre'`) - `images[].top` **[Number][7]?** the pixel offset from the top edge. - `images[].left` **[Number][7]?** the pixel offset from the left edge. - - `images[].tile` **[Boolean][8]** set to true to repeat the overlay image across the entire image with the given `gravity`. (optional, default `false`) + - `images[].tile` **[Boolean][9]** set to true to repeat the overlay image across the entire image with the given `gravity`. (optional, default `false`) - `images[].density` **[Number][7]** number representing the DPI for vector overlay image. (optional, default `72`) - `images[].raw` **[Object][4]?** describes overlay when using raw pixel data. - `images[].raw.width` **[Number][7]?** - `images[].raw.height` **[Number][7]?** - `images[].raw.channels` **[Number][7]?** - - `images[].create` **[Object][4]?** describes a blank overlay to be created. - - `images[].create.width` **[Number][7]?** - - `images[].create.height` **[Number][7]?** - - `images[].create.channels` **[Number][7]?** 3-4 - - `images[].create.background` **([String][6] \| [Object][4])?** parsed by the [color][9] module to extract values for red, green, blue and alpha. ### Examples @@ -74,8 +74,8 @@ Returns **Sharp** [7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[8]: https://www.npmjs.org/package/color -[9]: https://www.npmjs.org/package/color +[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean [10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error diff --git a/lib/composite.js b/lib/composite.js index 94e9c202..44f170f8 100644 --- a/lib/composite.js +++ b/lib/composite.js @@ -72,7 +72,12 @@ const blend = { * }); * * @param {Object[]} images - Ordered list of images to composite - * @param {Buffer|String} [images[].input] - Buffer containing image data or String containing the path to an image file. + * @param {Buffer|String} [images[].input] - Buffer containing image data, String containing the path to an image file, or Create object (see bellow) + * @param {Object} [images[].input.create] - describes a blank overlay to be created. + * @param {Number} [images[].input.create.width] + * @param {Number} [images[].input.create.height] + * @param {Number} [images[].input.create.channels] - 3-4 + * @param {String|Object} [images[].input.create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. * @param {String} [images[].blend='over'] - how to blend this image with the image below. * @param {String} [images[].gravity='centre'] - gravity at which to place the overlay. * @param {Number} [images[].top] - the pixel offset from the top edge. @@ -83,11 +88,6 @@ const blend = { * @param {Number} [images[].raw.width] * @param {Number} [images[].raw.height] * @param {Number} [images[].raw.channels] - * @param {Object} [images[].create] - describes a blank overlay to be created. - * @param {Number} [images[].create.width] - * @param {Number} [images[].create.height] - * @param {Number} [images[].create.channels] - 3-4 - * @param {String|Object} [images[].create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. * @returns {Sharp} * @throws {Error} Invalid parameters */