OpenVeo server API for plugins

API Docs for: 7.0.0
Show:

imageProcessor

Summary

Defines functions to manipulate images.

// Load module "imageProcessor"
var fsApi = require('@openveo/api').imageProcessor;

Methods

aggregate

Syntax

aggregate

(
  • imagesPaths
  • destinationPath
  • width
  • height
  • [horizontally=true]
  • [quality=90]
  • [temporaryDirectoryPath]
)
Function

Summary

Creates an image from a list of images.

Input images are aggregated horizontally or vertically to create the new image.

Parameters:

  • 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=true] Boolean optional

    true to aggregate images horizontally, false to aggregate them vertically

  • [quality=90] Number optional

    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/

Returns:

Function:

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]
)
Function

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 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=5] Number optional

    The number of images per line in the sprite

  • [maxRows=5] Number optional

    The maximum number of lines of images in the sprite

  • [quality=90] Number optional

    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/

Returns:

Function:

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]
)
Function

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 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=5] Number optional

    The number of images per line in the sprite

  • [maxRows=5] Number optional

    The maximum number of lines of images in the sprite

  • [quality=90] Number optional

    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/

Returns:

Function:

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

generateThumbnail

(
  • imagePath
  • thumbnailPath
  • [width]
  • [height]
  • [crop]
  • [quality]
)
Function

Summary

Generates a thumbnail from the given image.

Destination directory is automatically created if it does not exist.

Parameters:

  • 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)

Returns:

Function:

callback Function to call when its done with:

  • Error An error if something went wrong