module:image
- Description:
Scaling and composing images with Sharp.js
- Source:
Methods
(async, static) image.composite(items, defaultsopt) → {Array.<object>}
- Description:
Blend multiple images together, first image is used as the background for remaning items
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
items |
Array.<object> | list of objects representing an image or text, properties are given to module:image.create,
additional string property |
|
defaults |
object |
<optional> |
defaults global for all items, same parameters |
Returns:
| Type | Description |
|---|---|
| Array.<object> |
|
(static) image.convert(input, item) → {object}
- Description:
Apply Sharp image filters and conversions
- Source:
Parameters:
| Name | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
input |
object | sharp image |
||||||||
item |
object |
Properties
|
Returns:
| Type | Description |
|---|---|
| object |
transformed image |
(async, static) image.create(item) → {Promise}
- Description:
Create an image from a photo or text, supports raunded corners, borders
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
item |
object |
Properties
|
Returns:
| Type | Description |
|---|---|
| Promise |
|
(static) image.createGradient(item) → {Buffer}
- Description:
Generate an SVG radial-gradient ellipse overlay for an image item and return it as a Buffer.
Picks a gradient color (
gcolor) based onitem.coloranditem.gradient_type, adjusting for luminance/contrast, then builds an SVG sized toitem.meta.width/item.meta.height.
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
item |
Object |
Properties
|
Returns:
| Type | Description |
|---|---|
| Buffer |
SVG markup as a Buffer. |
(async, static) image.detect(item, bgimage)
- Description:
Detect a text color to place on top of the area inside given background
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
item |
object | input item |
bgimage |
object | Sharp image with background |
(static) image.gravityRegion(gravity, width, height) → {object}
- Description:
Return region corresponding to the gravity
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
gravity |
string | |
width |
int | |
height |
int |
Returns:
| Type | Description |
|---|---|
| object |
|
(static) image.mergeDefaults(item, defaultsopt) → {object}
- Description:
Merge defaults into an item, supports format
id.nameortype.namewhere id must match item.id and type item.type
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
item |
object | ||
defaults |
object |
<optional> |
Returns:
| Type | Description |
|---|---|
| object |
(static) image.padding(itemopt) → {Object}
- Description:
Normalize padding-related item into a rectangle object.
Accepts either side-specific padding values or axis-wide or single padding:
padding_top,padding_right,padding_bottom,padding_left(highest priority)padding_yapplies to top/bottom,padding_xapplies to left/rightpaddingapplies to all sides
Missing/undefined values are coerced via
lib.toNumber(...).
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
item |
object |
<optional> |
Input item object. Properties
|
Returns:
| Type | Description |
|---|---|
| Object |
Padding rectangle. |
(static) image.stats(input, regionopt) → {object}
- Description:
Return the stats about given region with inverted dominant color, if no region provided stats for the whole image
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
input |
Buffer | object | buffer or sharp object |
|
region |
object |
<optional> |
region to extract and return stats for |
Returns:
| Type | Description |
|---|---|
| object |
region stats with additional properties:
|