Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Image

warning

The Image API is partially supported on Linux platforms:

  • You can only load images of the PNG or JPG types
  • For more details, check doc center

Hierarchy

  • Image

Index

Properties

height

height: Number

Height of the image (pixels).

length

length: Number

Size of the image (bytes).

meta

meta: Object

Metadata associated with the image.

size

size: Number

Size of the image (bytes).

width

width: Number

Width of the image (pixels).

Methods

save

  • save(file: String, type?: String): void
  • save(file: WAKFileInstance, type?: String): void
  • Stores the image object in a file.

    Example 1: Basic usage

    var myImage = loadImage( 'PROJECT/my-image.jpg' );
    myImage.save( 'PROJECT/my-saved-image.jpg' );

    Example 2: Save image in another format

    var myImage = loadImage( 'PROJECT/my-image.jpg' );
    myImage.save( 'PROJECT/my-png-image.png', 'image/png' );
    warning

    Overrides existing files

    Parameters

    • file: String

      Path to the file where to save the image

    • Optional type: String

      New mime type to apply

    Returns void

  • Stores the image object in a file.

    Example 1: Basic usage

    var myFile = new File( 'PROJECT/my-saved-image.jpg' );
    var myImage = loadImage( 'PROJECT/my-image.jpg' );
    myImage.save( myFile );

    Example 2: Save image in another format

    var myFile = new File( 'PROJECT/my-png-image.png' );
    var myImage = loadImage( 'PROJECT/my-image.jpg' );
    myImage.save( myFile, 'image/png' );
    warning

    Overrides existing files

    Parameters

    • file: WAKFileInstance

      File object where to save the image

    • Optional type: String

      New mime type to apply

    Returns void

saveMeta

  • saveMeta(meta: Object): void
  • Updates the image metadata.

    var myImage = loadImage( 'PROJECT/my-image.jpg' );
    var newMeta = { IPTC: { Keywords: ['vacation', 'snow']}};
    myImage.saveMeta( newMeta );
    myImage.save( 'PROJECT/my-meta-image.jpg' );
    warning

    A save is required in order to save the metadata on disk

    Parameters

    • meta: Object

      Object containing the meta to update

    Returns void

thumbnail

  • thumbnail(width: Number, height: Number, mode?: Number): Image
  • Returns a thumbnail of the source image.

    Example 1: Basic usage

    var myImage = loadImage( 'PROJECT/my-image.jpg' );
    var myThumbnail = myImage.thumbnail( 50, 50 );
    myThumbnail.save( 'PROJECT/my-thumbnail.jpg' );

    Example 2: Change thumbnail mode

    var myImage = loadImage( 'PROJECT/my-image.jpg' );
    var myThumbnail = myImage.thumbnail( 50, 50, 2 );
    myThumbnail.save( 'PROJECT/my-thumbnail.jpg' );

    Parameters

    • width: Number

      (pixels) Thumbnail width

    • height: Number

      (pixels) Thumbnai height

    • Optional mode: Number

      (default: 6) Scale mode to apply. See doc center for more details.

    Returns Image