Add Watermark
Add a customizable text watermark to images with control over position, opacity, font, and more.
POST
/api/image/watermark
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
file | File | Yes | The image file to watermark. Supported formats: JPEG, PNG, WebP, BMP, TIFF. |
text | String | Yes | The text to use as a watermark. |
position | String | No | The position of the watermark. Options: top-left , top-center , top-right , center-left , center , center-right , bottom-left , bottom-center , bottom-right . Default: bottom-right . |
opacity | Float | No | The opacity of the watermark. Range: 0.1-1.0. Default: 0.5 . |
Response
Returns the watermarked image in the same format as the input file.
Example Request
// example.sh
curl -X POST "https://oyyi.xyz/api/image/watermark" -H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "file=@image.jpg" \
-F "text=© Copyright 2023" \
-F "position=bottom-right" \
-F "opacity=0.5" \
--output watermarked.jpg
Example with Python
// watermark.py
import requests
url = "https://oyyi.xyz/api/image/watermark"
files = {
'file': open('image.jpg', 'rb')
}
data = {
'text': '© Copyright 2023',
'position': 'bottom-right',
'opacity': 0.5
}
response = requests.post(url, files=files, data=data)
# Save the watermarked image
with open('watermarked.jpg', 'wb') as f:
f.write(response.content)
Example with JavaScript
// watermark.js
// Using fetch API
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('text', '© Copyright 2023');
formData.append('position', 'bottom-right');
formData.append('opacity', '0.5');
fetch('https://oyyi.xyz/api/image/watermark', {
method: 'POST',
body: formData
})
.then(response => response.blob())
.then(blob => {
// Create a URL for the blob
const url = URL.createObjectURL(blob);
// Create a link to download the image
const a = document.createElement('a');
a.href = url;
a.download = 'watermarked.jpg';
a.click();
// Clean up by revoking the URL
URL.revokeObjectURL(url);
})
.catch(error => console.error('Error:', error));
Watermark Positions
top-left
top-center
top-right
center-left
center
center-right
bottom-left
bottom-center
bottom-right
How It Works
The watermark endpoint adds text to an image with customizable appearance and positioning:
- Text Rendering: The specified text is rendered using the selected font, size, and color.
- Opacity Adjustment: The rendered text is made semi-transparent according to the opacity parameter.
- Shadow (Optional): If enabled, a subtle shadow is added behind the text to improve visibility against varying backgrounds.
- Rotation (Optional): The text is rotated by the specified angle.
- Positioning: The watermark is placed at the specified position with the given padding from the edges.
- Compositing: The watermark is overlaid onto the original image.
The result is an image with a customized text watermark that can be used for branding, copyright protection, or attribution.
Font Examples
Arial
Clean, modern sans-serif font. Good for most uses.
Times
Classic serif font. Good for formal or traditional looks.
Courier
Monospaced font. Good for technical or code-like appearance.
Error Responses
Status Code | Description |
---|---|
400 | Bad request. Missing required parameters, invalid position, invalid opacity value, invalid font size, invalid font, invalid color, invalid padding, invalid rotation, or invalid file format. |
413 | Payload too large. The file size exceeds the maximum allowed limit. |
500 | Internal server error. Something went wrong on the server. |
Notes
- For optimal visibility, consider using a light color with shadow enabled on dark images, or a dark color on light images.
- The bottom-right position is commonly used for copyright notices and attribution.
- For diagonal watermarks across the entire image, use the center position with rotation set to 45 degrees and a larger font size.
- The opacity parameter is useful for making the watermark less intrusive while still visible.
- The maximum file size allowed is 10MB.
- This operation preserves the alpha channel (transparency) if present in the original image.
- Special characters and Unicode are supported in the watermark text, including copyright symbols (©), trademark symbols (™), and emojis.
Use Cases
- Adding copyright notices to protect intellectual property
- Branding images with company or personal logos
- Adding attribution or credit information to shared images
- Marking images as drafts or proofs
- Adding date stamps or location information to photographs
- Creating branded social media content
- Marking confidential or internal-use-only documents