A high-performance Node.js API for adding watermarks to images with automatic CDN upload. Built with Express, Sharp, and Canvas, this API processes images from URLs, adds watermarks at specified positions, and automatically uploads the results to your CDN.
- Fast Image Processing: Built on Sharp for high-performance image manipulation
- Automatic CDN Uploads: All processed images are automatically uploaded to
sam-cdn.zone.id - Flexible Positioning: Watermark placement at bottom-left or bottom-right corners
- Dual Endpoints: Support for both GET and POST requests
Clone & Install
git clone https://github.com/Lord-Samuel/Watermark-Api.git
cd watermark-api
npm install
npm startAPI Endpoints
GET /api/watermark
GET /api/watermark?url=<image_url>&watermarkUrl=<watermark_url>&position=<left|right>
POST /api/watermark
POST /api/watermark
Content-Type: application/json
{
"url": "<image_url>",
"watermarkUrl": "<watermark_url>",
"position": "right"
}JavaScript Fetch Example
const response = await fetch('http://localhost:3000/api/watermark', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
url: 'https://example.com/image.jpg',
watermarkUrl: 'https://example.com/logo.png',
position: 'left'
})
});
const data = await response.json();
console.log('CDN URL:', data.results.url);
console.log('Processing speed:', data.speed + 'ms');Response Format
Success Response (200 OK)
{
"success": true,
"creator": "SamuelRebix",
"speed": 48042,
"results": {
"url": "http://sam-cdn.zone.id/files/qLCkim.png",
"fileId": "qLCkim.png"
},
"metadata": {
"mainImage": {
"width": 1919,
"height": 1137,
"format": "png"
},
"watermark": {
"resizedWidth": 171,
"resizedHeight": 101,
"position": {
"x": 1710,
"y": 1013
}
}
}
}