imageProcessor
Summary
Defines functions to manipulate images.
// Load module "imageProcessor"
var fsApi = require('@openveo/api').imageProcessor;
Item Index
Methods
aggregate
Syntax
aggregate
-
imagesPaths
-
destinationPath
-
width
-
height
-
[horizontally=true]
-
[quality=90]
-
[temporaryDirectoryPath]
Summary
Creates an image from a list of images.
Input images are aggregated horizontally or vertically to create the new image.
Parameters:
-
imagesPaths
ArrayThe list of paths of the images to add to the final image
-
destinationPath
StringThe final image path
-
width
NumberThe width of input images inside the image (in px)
-
height
NumberThe height of input images inside the image (in px)
-
[horizontally=true]
Boolean optionaltrue to aggregate images horizontally, false to aggregate them vertically
-
[quality=90]
Number optionalExpected quality from 0 to 100 (default to 90 with 100 the best)
-
[temporaryDirectoryPath]
String optionalPath 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/
Returns:
callback Function to call when its done with:
- Error An error if something went wrong
- Array The list of images with:
- String sprite The path of the sprite file containing the image (destinationPath)
- String image The path of the original image
- Number x The x coordinate of the image top left corner inside the sprite
- Number y The y coordinate of the image top left corner inside the sprite
generateSprite
Syntax
generateSprite
-
imagesPaths
-
destinationPath
-
width
-
height
-
[totalColumns=5]
-
[maxRows=5]
-
[quality=90]
-
[temporaryDirectoryPath]
Summary
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:
-
imagesPaths
ArrayThe list of images path to include in the sprite
-
destinationPath
StringThe sprite path
-
width
NumberThe width of images inside the sprite (in px)
-
height
NumberThe height of images inside the sprite (in px)
-
[totalColumns=5]
Number optionalThe number of images per line in the sprite
-
[maxRows=5]
Number optionalThe maximum number of lines of images in the sprite
-
[quality=90]
Number optionalExpected quality from 0 to 100 (default to 90 with 100 the best)
-
[temporaryDirectoryPath]
String optionalPath 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/
Returns:
callback Function to call when its done with:
- Error An error if something went wrong
- Array The list of images with:
- String sprite The path of the sprite file containing the image (destinationPath)
- String image The path of the original image
- Number x The x coordinate of the image top left corner inside the sprite
- Number y The y coordinate of the image top left corner inside the sprite
generateSprites
Syntax
generateSprites
-
imagesPaths
-
destinationPath
-
width
-
height
-
[totalColumns=5]
-
[maxRows=5]
-
[quality=90]
-
[temporaryDirectoryPath]
Summary
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:
-
imagesPaths
ArrayThe list of images paths to include in the sprites
-
destinationPath
StringThe first sprite path, additional sprites are suffixed by a number
-
width
NumberThe width of images inside the sprite (in px)
-
height
NumberThe height of images inside the sprite (in px)
-
[totalColumns=5]
Number optionalThe number of images per line in the sprite
-
[maxRows=5]
Number optionalThe maximum number of lines of images in the sprite
-
[quality=90]
Number optionalExpected quality from 0 to 100 (default to 90 with 100 the best)
-
[temporaryDirectoryPath]
String optionalPath 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/
Returns:
callback Function to call when its done with:
- Error An error if something went wrong
- Array The list of images with:
- String sprite The path of the sprite file containing the image
- String image The path of the original image
- Number x The x coordinate of the image top left corner inside the sprite
- Number y The y coordinate of the image top left corner inside the sprite
generateThumbnail
Syntax
Summary
Generates a thumbnail from the given image.
Destination directory is automatically created if it does not exist.
Parameters:
-
imagePath
StringThe image absolute path
-
thumbnailPath
StringThe thumbnail path
-
[width]
Number optionalThe expected image width (in px)
-
[height]
Number optionalThe expected image height (in px)
-
[crop]
Boolean optionalCrop the image if the new ratio differs from original one
-
[quality]
Number optionalExpected quality from 0 to 100 (default to 90 with 100 the best)
Returns:
callback Function to call when its done with:
- Error An error if something went wrong