Appearance
Image Watermarking
Welcome to the Image Watermarking API documentation! This API allows you to apply watermarks to images, supporting both text and image watermarks. Below, you'll find details on how to use the API, including example requests and responses.
API Endpoints
/watermark
This endpoint handles the process of adding watermarks to images.
Header Parameters
X-RapidAPI-Key (Required)
Your Rapid API Key, Used to authenticate and manange your subscription
File Parameters
watermarkImage(Required): The image file to be used as a watermark.image(Required): The image file to be watermarked.
Body Parameters
watermarkText(Optional): The text to be used as a watermark (ifwatermarkTypeis set to 'text').watermarkType(Optional): The type of watermark ('text' or 'image'). Default is 'image'.gravity(Optional): The position to place the watermark on the image (e.g., 'southeast', 'center'). Default is 'southeast'.resize(Optional): An object specifying the width and height to resize the watermark.tile(Optional): Whether to tile the watermark across the image. Default is false.watermarkOpacity(Optional): The opacity of the watermark. Default is 0.90.opacity(Optional): The overall opacity of the watermarked image. Default is 1.blend(Optional): The blending mode for the watermark. Default is 'over'.offset(Optional): An object specifying the top and left offset for the watermark.filename(Optional): The filename for the watermarked image.radius(Optional): The radius for rounding the corners of the watermark. Default is 10.font(Optional): The font family for the text watermark. Default is 'Arial'.textSize(Optional): The font size for the text watermark. Default is 40.textFill(Optional): The color of the text watermark. Default is 'white'.textX(Optional): The x-position of the text watermark. Default is 0.textY(Optional): The y-position of the text watermark. Default is 27.
Response
If successful, the API returns the watermarked image.
Error Codes
400: Bad request.500: Internal server error.
Example Usage
cURL Example
bash
curl -X POST https://your-api-endpoint/watermark \
-H "Content-Type: multipart/form-data" \
-F "watermarkImage=@path/to/watermark.png" \
-F "image=@path/to/image.jpg" \
-F "watermarkType=image" \
-F "gravity=southeast" \
-F "resize={\"width\": 100, \"height\": 100}" \
-F "tile=true" \
-F "watermarkOpacity=0.8" \
-F "opacity=0.9" \
-F "blend=over" \
-F "offset={\"top\": 10, \"left\": 20}" \
-F "filename=watermarked_image.jpg"
-H "X-RapidAPI-Key: Your-RapidAPI-Key"Replace Your-RapidAPI-Key with the actual key provided by RapidAPI.
This request applies a watermark to the image using the specified parameters.
Node.js Example
javascript
const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');
const apiUrl = 'https://your-api-endpoint/watermark';
const rapidAPIKey = 'Your-RapidAPI-Key';
const formData = new FormData();
formData.append('watermarkImage', fs.createReadStream('path/to/watermark.png'));
formData.append('image', fs.createReadStream('path/to/image.jpg'));
formData.append('watermarkType', 'image');
formData.append('gravity', 'southeast');
formData.append('resize', '{"width": 100, "height": 100}');
formData.append('tile', 'true');
formData.append('watermarkOpacity', '0.8');
formData.append('opacity', '0.9');
formData.append('blend', 'over');
formData.append('offset', '{"top": 10, "left": 20}');
formData.append('filename', 'watermarked_image.jpg');
axios.post(apiUrl, formData, {
headers: {
...formData.getHeaders(),
'X-RapidAPI-Key': rapidAPIKey,
},
})
.then(response => {
// Process the watermarked image response
console.log(response.data);
})
.catch(error => {
// Handle errors
console.error(error.response.data);
});Again, replace Your-RapidAPI-Key with the actual key provided by RapidAPI.
This Node.js example demonstrates how to use the API to watermark an image with the specified parameters.
Feel free to adjust the parameters based on your requirements. Make sure to replace https://your-api-endpoint/watermark with the actual URL of your watermarking API.