Class representing the TrustMark watermark. This class utilizes ECC (Error Correction Codes) and ONNX models for encoding and decoding.

Constructors

  • Constructs a new TrustMark instance.

    Parameters

    • Optionaluse_ecc: boolean = true

      use BCH error correction on the payload, reducing payload size (default)

    • Optionalsecret_len: number = 100

      The length of the secret.

    • Optionalencoding_mode: number = TrustMark.encoding.BCH_4

      The data schema encoding mode to use.

    Returns TrustMark

Properties

decoder_session: any
encoder_session: any
model_type: undefined | string
preprocess_224_session: any
preprocess_256_session: any
secret_len: number
use_ecc: boolean
encoding: {
    BCH_3: number;
    BCH_4: number;
    BCH_5: number;
    BCH_SUPER: number;
    undefined: number;
} = ...
  • Static encoding mapping for different BCH modes.

Methods

  • Decodes the watermark of an image from a given URL.

    Parameters

    • image_url: string

      The URL of the image to decode.

    Returns Promise<any>

    A promise that resolves to the decoded watermnark data.

  • Encodes a secret into an image and returns the stego image and the residual image.

    Parameters

    • image_url: string

      The cover image data.

    • string_secret: string

      The secret string to encode.

    • wm_strength: number = 0.4

      The watermark strength. Default is 0.4.

    • maculate: boolean = false

      Whether to overwrite an existing watermark with random values. Default is false.

    • output: string = 'bytes'

      The output format. Default is 'bytes'.

    Returns Promise<any>

    A promise that resolves with the encoded data or rejects with an error.

  • Loads an image from a URL or filesystem and processes it based on the specified type.

    Parameters

    • image_url: string

      The URL or filesystem path of the image to be loaded.

    • process_type: string

      The type of processing to be applied to the image.

    Returns Promise<any>

    A promise that resolves with the processed image.

    Throws an error if there is an issue loading or processing the image.

  • Loads the necessary models based on the specified type.

    Parameters

    • Optionaltype: string = 'Q'

      The type of models to load ('Q' or 'P').

    Returns Promise<void>

    Throws an error if there is an issue loading any of the models.

  • Processes the input image based on the specified processing type.

    Parameters

    • image: any

      The image object containing the tensor source and other properties.

    • process_type: string

      The type of processing to be applied to the image ('decode' or other types).

    Returns Promise<any>

    A promise that resolves with the processed image.

    Throws an error if there is an issue processing the image.