Defines functions to manipulate images.
- Source:
Example
// Load module "imageProcessor"
var fsApi = require('@openveo/api').imageProcessor;
Methods
(static) aggregate(imagesPaths, destinationPath, width, height, horizontallyopt, qualityopt, temporaryDirectoryPathopt) → {module:imageProcessor~aggregateCallback}
Creates an image from a list of images.
Input images are aggregated horizontally or vertically to create the new image.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
imagesPaths |
Array | The list of paths of the images to add to the final image |
||
destinationPath |
String | The final image path |
||
width |
Number | The width of input images inside the image (in px) |
||
height |
Number | The height of input images inside the image (in px) |
||
horizontally |
Boolean |
<optional> |
true | true to aggregate images horizontally, false to aggregate them vertically |
quality |
Number |
<optional> |
90 | Expected quality from 0 to 100 (default to 90 with 100 the best) |
temporaryDirectoryPath |
String |
<optional> |
Path to the temporary directory to use to store intermediate images. It will be removed at the end of the operation. If not specified a directory is created in /tmp/ |
- Source:
Returns:
callback Function to call when its done
(static) generateSprite(imagesPaths, destinationPath, width, height, totalColumnsopt, maxRowsopt, qualityopt, temporaryDirectoryPathopt) → {module:imageProcessor~generateSpriteCallback}
Generates a sprite from a list of images.
If the number of images exceeds the maximum number of images (depending on totalColumns and maxRows), extra images won't be in the sprite.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
imagesPaths |
Array | The list of images path to include in the sprite |
||
destinationPath |
String | The sprite path |
||
width |
Number | The width of images inside the sprite (in px) |
||
height |
Number | The height of images inside the sprite (in px) |
||
totalColumns |
Number |
<optional> |
5 | The number of images per line in the sprite |
maxRows |
Number |
<optional> |
5 | The maximum number of lines of images in the sprite |
quality |
Number |
<optional> |
90 | Expected quality from 0 to 100 (default to 90 with 100 the best) |
temporaryDirectoryPath |
String |
<optional> |
Path to the temporary directory to use to store intermediate images. It will be removed at the end of the operation. If not specified a directory is created in /tmp/ |
- Source:
Returns:
callback Function to call when its done
(static) generateSpriteFreely(imagesPaths, destinationPath, qualityopt, temporaryDirectoryPathopt) → {module:imageProcessor~generateSpriteFreelyCallback}
Generates a sprite from a list of images without specifying images sizes nor grid size.
Size of images aren't changed. Images or simply packed by height with all images of the same height on the same line starting by images with higher height.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
imagesPaths |
Array | The list of images path to include in the sprite |
||
destinationPath |
String | The sprite path |
||
quality |
Number |
<optional> |
90 | Expected quality from 0 to 100 (default to 90 with 100 the best) |
temporaryDirectoryPath |
String |
<optional> |
Path to the temporary directory to use to store intermediate images. It will be removed at the end of the operation. If not specified a directory is created in /tmp/ |
- Source:
Returns:
callback Function to call when its done
(static) generateSprites(imagesPaths, destinationPath, width, height, totalColumnsopt, maxRowsopt, qualityopt, temporaryDirectoryPathopt) → {module:imageProcessor~generateSpritesCallback}
Generates sprites from a list of images.
If the number of images don't fit in the grid defined by totalColumns * maxRows, then several sprites will be created. Additional sprites are suffixed by a number.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
imagesPaths |
Array | The list of images paths to include in the sprites |
||
destinationPath |
String | The first sprite path, additional sprites are suffixed by a number |
||
width |
Number | The width of images inside the sprite (in px) |
||
height |
Number | The height of images inside the sprite (in px) |
||
totalColumns |
Number |
<optional> |
5 | The number of images per line in the sprite |
maxRows |
Number |
<optional> |
5 | The maximum number of lines of images in the sprite |
quality |
Number |
<optional> |
90 | Expected quality from 0 to 100 (default to 90 with 100 the best) |
temporaryDirectoryPath |
String |
<optional> |
Path to the temporary directory to use to store intermediate images. It will be removed at the end of the operation. If not specified a directory is created in /tmp/ |
- Source:
Returns:
callback Function to call when its done
(static) generateThumbnail(imagePath, thumbnailPath, widthopt, heightopt, cropopt, qualityopt, callback)
Generates a thumbnail from the given image.
Destination directory is automatically created if it does not exist.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
imagePath |
String | The image absolute path |
|
thumbnailPath |
String | The thumbnail path |
|
width |
Number |
<optional> |
The expected image width (in px) |
height |
Number |
<optional> |
The expected image height (in px) |
crop |
Boolean |
<optional> |
Crop the image if the new ratio differs from original one |
quality |
Number |
<optional> |
Expected quality from 0 to 100 (default to 90 with 100 the best) |
callback |
callback | Function to call when its done |
- Source:
Type Definitions
aggregateCallback(error, images)
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
error |
Error | null | The error if an error occurred, null otherwise |
|||||||||||||||
images |
Array | The list of images Properties
|
- Source:
generateSpriteCallback(error, images)
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
error |
Error | null | The error if an error occurred, null otherwise |
|||||||||||||||
images |
Array | The list of images Properties
|
- Source:
generateSpriteFreelyCallback(error, sprite)
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
error |
Error | null | The error if an error occurred, null otherwise |
|||||||||||||||||||||||||||||||||
sprite |
Object | The generated image Properties
|
- Source:
generateSpriteFreelyInternalCallback(error, sprite)
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
error |
Error | null | The error if an error occurred, null otherwise |
|||||||||||||||||||||
sprite |
Object | The generated image Properties
|
- Source:
generateSpritesCallback(error, images)
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
error |
Error | null | The error if an error occurred, null otherwise |
|||||||||||||||
images |
Array | The list of images Properties
|
- Source: