Skip to main content
warning

There is a pending German patent application with the application number 10 2023 125 012.4. In order to use the TREND watermarker Software in the form published here, a patent license is required in addition to the license for the Software. See LICENSE for more information. In case of any questions or uncertainties, please contact us at trend@isst.fraunhofer.de.

JavaScript

If you want to use watermarking inside your JavaScript project, this page gives you the necessary information.

Compile the Library

See Installation.

Plain JavaScript

In order to use this library in plain JavaScript, follow these steps:

  1. Build the library (see above)
  2. Import the generated JS library:
    <script src='[relative-path-to]/TREND/watermarker/build/dist/js/productionExecutable/watermarker.js'></script>
  3. This generates a variable watermarkers that provides access to the library functionalities. However, the actual watermarker object is behind the package path and you might want to reassign the watermarker variable to get rid of the long path like this:
    watermarker = watermarker.de.fraunhofer.isst.trend.watermarker;
  4. Now you are ready to use the watermarker in plain JS. An example HTML file can be found in the repositories' examples.

You can open the file in the browser, no web server required.

JavaScript Modules

In order to use this library in JavaScript modules, follow these steps:

  1. Build the library (see above)

  2. Import the generated JS library according to your module system:

    // CommonJS (CJS)
    let watermarker = require('[relative-path-to]/TREND/watermarker/build/dist/js/productionExecutable/watermarker.js'); // built as executable
    // or
    let watermarker = require('[relative-path-to]/TREND/watermarker/build/js/packages/watermarker/kotlin/watermarker.js'); // built as module

    // ECMAScript Modules (ESM)
    import watermarker from '[relative-path-to]/TREND/watermarker/build/dist/js/productionExecutable/watermarker.js'; // built as executable
    // or
    import watermarker from '[relative-path-to]/TREND/watermarker/build/js/packages/watermarker/kotlin/watermarker.js'; // built as module
  3. This generates a variable watermarker that provides access to the library functionalities. However, the actual watermarker object is behind the package path and you might want to reassign the watermarker variable to get rid of the long path like this:

    watermarker = watermarker.de.fraunhofer.isst.trend.watermarker;

    Note that imports in ESM are implicitly constant.

  4. Now you are ready to use the watermarker in your module. An example node script can be found in the repositories' examples.

Run it using node npm_minimal_example.js.