Minomax API Reference

The Minomax class provides a set of tools for processing images, videos, and web documents. Its public APIs allow developers to manage tasks like video encoding, image compression, thumbnail generation, image set generation, and web document ( Javascript, CSS, HTML ) minification. Below is a detailed reference for the public methods exposed by this class.


Constructor

The Minomax constructor initializes a new instance of the Minomax class with configurations and worker instances.

Usage

const minomaxInstance = new Minomax();

Methods

1. minomax()

This method is typically used in a post-deployment pipeline to prepare deployment files by processing and optimizing them. It includes tasks such as generating image sets, compressing images and videos, minifying web documents (such as JavaScript, CSS, HTML), and including video thumbnails.

Parameters
  • imageWorkerParams (optional): Specifies parameters for image processing, including the target format.

    Type:

    {
      targetFormat: "jpg" | "avif" | "webp" | "svg";
    }

    Default: { targetFormat: this.configurations.imageWorker.encoding.targetType }


  • videoWorkerParams (optional): Specifies parameters for video processing, including codec type and encoding level.

    Type:

    {
      codecType: "wav1" | "mav1" | "mx265";
      encodeLevel: 1 | 2 | 3;
    }

    Default: this.configurations.videoWorker.encoding


  • ignorePatterns (optional): Patterns to ignore during file searches.

    Type: string[]

    Default: this.configurations.ignorePatterns


  • webDocLookUpPatterns (optional): File patterns for locating web documents.

    Type: string[]

    Default: this.configurations.lookUpPatterns.webDoc


  • destinationBasePath (optional): Directory for storing processed files.

    Type: string

    Default: this.configurations.destPath


  • removeOld (optional): Whether to delete old files in the destination directory.

    Type: boolean

    Default: this.configurations.removeOld

Returns

Type: Promise<{ availableImages: string[]; availableVideos: string[]; thumnailCount: number }>

An object with lists of available images and videos, and the count of thumbnails generated.


2. compressImages()

Compresses image files based on the given lookup patterns and target format.

Parameters
  • targetFormat (optional): Target image format.

    Type: "jpg" | "avif" | "webp" | "svg"

    Default: this.configurations.imageWorker.encoding.targetType


  • lookUpPatterns (optional): Patterns to find image files.

    Type: string[]

    Default: this.configurations.lookUpPatterns.image


  • destinationBasePath (optional): Directory for storing compressed images.

    Type: string

    Default: this.configurations.destPath


  • ignorePatterns (optional): Patterns to ignore during file searches.

    Type:string[]

    Default: this.configurations.ignorePatterns


Returns

Type: Promise<void>


3. compressVideos()

Compresses video files using the specified codec and encoding level.

Parameters
  • codecType (optional): Specifies the video codec.

    Type: "wav1" | "mav1" | "mx265"

    Default: this.configurations.videoWorker.encoding.codecType


  • lookUpPatterns (optional): Patterns to find video files.

    Type: string[]

    Default: this.configurations.lookUpPatterns.video


  • encodeLevel (optional): Encoding level for video compression.

    Type: 1 | 2 | 3

    Default: this.configurations.videoWorker.encoding.encodeLevel


  • destinationBasePath (optional): Directory for storing compressed videos.

    Type: string

    Default: this.configurations.destPath


  • ignorePatterns (optional): Patterns to ignore during file searches.

    Type: string[]

    Default: this.configurations.ignorePatterns

Returns

Type: Promise<void>


4. makeVideoThumbnail()

Generates video thumbnails and links them to HTML files.

Parameters
  • htmlFiles (not required if htmlLookupPattern passed): List of HTML files to process.

    Type: string[]


  • htmlLookupPattern (not required if htmlFiles passed): File patterns to locate HTML files.

    Type: string[]


  • seekPercentage (optional): Position (as a percentage) in the video to capture the thumbnail.

    Type: number

    Default: 15


  • variableImgFormat (optional): Specifies the format of the generated thumbnails.

    Type: "jpg" | "avif" | "webp" | "svg" | false

    Default: false


  • videoCodec (optional): Specifies the video codec.

    Type: "wav1" | "mav1" | "mx265" | false

    Default: false


  • ignorePatterns (optional): Patterns to ignore during file searches.

    Type: string[] | string

    Default: this.configurations.ignorePatterns


  • basePath (optional): Base directory for relative paths.

    Type: string

    Default: ""

Returns

Type: Promise<Record<string, string>>

A mapping of video file paths to their corresponding thumbnail paths.


5. generateImageSets()

Generates responsive image sets for small to large devices, linking them to the respective <img> or <picture> tags with media queries.

Parameters
  • lookUpPatterns (optional): Patterns used to locate HTML files for processing.

    Type: string[]

    Default: this.configurations.lookUpPatterns.webDoc


  • destinationBasePath (optional): The base directory where the image sets will be saved.

    Type: string

    Default: this.configurations.destPath


  • ignorePatterns (optional): A list of patterns to exclude during file searches.

    Type: string[]

    Default: this.configurations.ignorePatterns

Returns

Type: Promise<void>


6. minifyWebdoc()

Minifies web documents (HTML, CSS, JS) to optimize file sizes and improve load times.

Parameters
  • lookUpPatterns (optional): Patterns to locate the web documents for processing.

    Type: string[]

    Default: this.configurations.lookUpPatterns.webDoc


  • lookUpBasePath (optional): Base directory to start the file search.

    Type: string

    Default: process.cwd()


  • destinationBasePath (optional): Directory where the minified files will be saved.

    Type: string

    Default: this.configurations.destPath


  • ignorePatterns (optional): Patterns to ignore during the file search process.

    Type: string[]

    Default: this.configurations.ignorePatterns

Returns

Type: Promise<void>


For detailed command-line usage and options, proceed to the CLI Reference on the next page.


Keywords:
  • API reference
  • Minomax API
  • Web optimization API
  • Image processing API
  • Video thumbnail API
  • Image set generation
  • Encoding options API
  • Web document minification API
  • API usage
  • CLI integration