API Reference

Complete reference documentation for all functions and types in the images-watermark npm package. Learn how to use singleImageWatermark and multiImageWatermark functions.

singleImageWatermark

Adds watermarks (text, image, or both) to a single image with customizable styling and security options. This is the most popular function in the images-watermark npm package.

Usage

1await singleImageWatermark({
2  imagePath: './input.jpg',         // Required: Path to input image
3  allowedReferrers: ['http://localhost:3000'], // Required: Allowed domains for CORS
4  headers: {                        // Required: Headers for API calls
5    host: 'localhost:3000',
6    connection: 'keep-alive',
7    'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
8  },
9  textWatermark: 'My Watermark',    // Optional: Text to add as watermark
10  textColor: '#ffffff',             // Optional: Text color (default: '#000000')
11  opacity: '0.8',                   // Optional: Opacity 0-1 (default: '0.3')
12  fontWeight: '600',                // Optional: Font weight (default: '400')
13  textLineSpacing: 1.2,             // Optional: Line spacing (default: 1)
14  fontFamily: 'Inter, Arial, sans-serif', // Optional: Font family
15  appName: 'My App'                 // Optional: Application name for branding
16});

Parameters

ParameterTypeRequiredDescription
imagePath
string
Required
Path to the input image file
headers
object
Required
Headers for API calls (host, connection, user-agent)
allowedReferrers
array
Required
List of allowed domains for CORS
watermarkPath
string
Optional
Path to the watermark image file
textWatermark
string
Optional
Text content for the watermark
appName
string
Optional
Application name for branding purposes
textColor
string
Optional
Text color (hex format, default: "#000000")
opacity
string
Optional
Opacity from 0 to 1 (default: "0.3")
fontWeight
string
Optional
Font weight (default: "400")
textLineSpacing
number
Optional
Line spacing for text watermark (default: 1)
fontFamily
string
Optional
Font family (default: "Inter, Arial, sans-serif")

Popular Search Terms

Common questions and search terms related to the images-watermark npm package API:

Function Names

• singleImageWatermark
• multiImageWatermark
• image watermark api

Package Related

• images watermark npm
• watermark npm package
• node.js watermark api

Technical Terms

• typescript watermark api
• javascript watermark library
• batch image watermarking

Position Options

The position parameter accepts the following values:

top-leftTop left corner
top-centerTop center
top-rightTop right corner
center-leftCenter left
centerCenter of image
center-rightCenter right
bottom-leftBottom left corner
bottom-centerBottom center
bottom-rightBottom right corner

TypeScript Types

Complete type definitions for TypeScript users:

types.ts
1interface SingleImageWatermarkOptions {
2  imagePath: string;
3  headers: {
4    host: string;
5    connection: string;
6    'user-agent': string;
7  };
8  allowedReferrers: string[];
9  watermarkPath?: string;
10  textWatermark?: string;
11  appName?: string;
12  textColor?: string;
13  opacity?: string;
14  fontWeight?: string;
15  textLineSpacing?: number;
16  fontFamily?: string;
17}
18
19interface MultiImageWatermarkOptions {
20  imagePaths: string[];
21  headers: {
22    host: string;
23    connection: string;
24    'user-agent': string;
25  };
26  allowedReferrers: string[];
27  watermarkPath?: string;
28  textWatermark?: string;
29  appName?: string;
30  textColor?: string;
31  opacity?: string;
32  fontWeight?: string;
33  textLineSpacing?: number;
34  fontFamily?: string;
35}