A lightweight MCP component for adding text watermarks to pictures
Project description
๐ฏ Stamp it - Apply a full-screen watermark to an image
A professional image watermarking service built with FastMCP, supporting both text and image watermarks with intelligent color adaptation.
ไธญๆๆๆกฃ | English
โจ Key Features
- ๐ผ๏ธ Dual Watermark Modes: Support for both text and image watermarks
- ๐ Local File Processing: Professional local image file handling
- ๐จ Smart Adaptive Colors: Automatic color selection based on image brightness
- ๐ Tilted Watermark Effects: Customizable angle tilting (default 30ยฐ upward right)
- ๐ Multi-language Support: Chinese, English, Japanese, Korean and more
- ๐ฏ High-density Coverage: Complete coverage of every corner with no gaps
- ๐ High Definition: BICUBIC resampling for smooth edges
- ๐ Smart Saving: Auto-save in the same directory as original image
- โก Performance Optimized: Font caching, intelligent scaling, memory management
- ๐ ๏ธ Rich Format Support: Supports 7 common image formats
๐ Usage
MCP Client Configuration
Cherry Studio (Recommended)
-
Open Cherry Studio Settings
- Go to Settings โ MCP Servers
- Click "Add Server"
-
Configure MCP Server
-
Save and Connect
- Click "Save" to add the server
- The server will automatically connect
- You can now use the watermark tools in Cherry Studio
Cursor
-
Open Cursor Settings
- Use shortcut
Cmd+,(Mac) orCtrl+,(Windows/Linux) - Or click Settings โ Preferences
- Use shortcut
-
Configure MCP Server
- Find "MCP Servers" configuration option
- Add the following configuration:
{
"mcpServers": {
"stampit": {
"command": "uvx",
"args": [
"mcp-stampit"
]
}
}
}
- Save and Restart
- Save the configuration file
- Restart Cursor for changes to take effect
- You can now use the watermark tools in Cursor
๐ฆ Preview
๐ Installation
Using uv (Recommended)
# Install dependencies
uv pip install fastmcp pillow
# Or install using project configuration
uv pip install -e .
Using pip
pip install fastmcp pillow
Start the MCP Server (Standalone)
python main.py
After the server starts, you will see output similar to:
โญโ FastMCP 2.0 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ ๐ฅ๏ธ Server name: Stamp it - Apply a full-screen watermark to an image โ
โ ๐ฆ Transport: STDIO โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Available MCP Tools
add_text_watermark - Text Watermark
Add intelligent text watermarks to images with multi-language support and adaptive colors.
Parameters:
image_path(str): Local image file pathwatermark_text(str): Watermark text contentangle(float, optional): Watermark tilt angle, default 30ยฐ
Usage Examples:
# Basic text watermark
add_text_watermark("/Users/photos/vacation.jpg", "My Copyright")
# Custom angle
add_text_watermark("./document.png", "Confidential", angle=45)
# Multi-language watermark
add_text_watermark("photo.jpg", "Copyright ยฉ 2024 All Rights Reserved")
add_image_watermark - Image Watermark
Add image watermarks to photos, supporting logos, signatures, and other images as watermarks.
Parameters:
image_path(str): Local image file pathwatermark_image_path(str): Watermark image file pathangle(float, optional): Watermark tilt angle, default 30ยฐ
Usage Examples:
# Add logo watermark
add_image_watermark("/Users/photos/product.jpg", "/Users/logos/company_logo.png")
# Custom angle logo watermark
add_image_watermark("photo.jpg", "signature.png", angle=0)
# Brand watermark
add_image_watermark("marketing_image.jpg", "brand_watermark.png", angle=15)
๐จ Watermark Features
๐ Text Watermark Features
-
Smart Color Adaptation
- Bright images: Automatically use dark watermarks (RGB 20,20,20)
- Dark images: Automatically use light/white watermarks (RGB 240,240,240)
- Medium brightness: Intelligently select optimal contrast colors
-
Multi-language Font Support
- Auto-detect and load system's best Chinese fonts
- Support for PingFang SC, Microsoft YaHei, SimHei, etc.
- Perfect display of Chinese, Japanese, Korean, and English
-
High-quality Rendering
- Font caching for improved performance
- BICUBIC resampling for smooth edges
- Centered rendering with excellent rotation effects
๐ผ๏ธ Image Watermark Features
- Smart Scaling: Auto-scale to appropriate size (default 15%)
- Opacity Control: Automatic opacity adjustment without affecting original image
- Aspect Ratio Preservation: Maintain watermark image aspect ratio
- High-quality Scaling: Use LANCZOS algorithm for clarity
๐ฏ Layout Algorithm
- Complete Coverage: Start from outside image boundaries for 100% coverage
- Staggered Arrangement: Odd-even row offset for more natural visual effect
- Dense Distribution: Optimized spacing algorithm, 40% higher density than traditional methods
- Edge Handling: Complete watermark coverage in all four corners
๐ File Output
Save Rules
- Save Location: Auto-save in the same directory as original image
- Naming Convention: Original filename +
_watermark+ extension - Format Preservation: Maintain original image format and quality
- Optimized Saving: Enable compression optimization to reduce file size
Output Examples
Input: /Users/photos/vacation.jpg
Output: /Users/photos/vacation_watermark.jpg
Input: ./designs/logo.png
Output: ./designs/logo_watermark.png
Input: document.pdf.png
Output: document.pdf_watermark.png
๐ ๏ธ Supported Image Formats
| Format | Extensions | Read | Save | Transparency | Optimized |
|---|---|---|---|---|---|
| JPEG | .jpg, .jpeg | โ | โ | โ | โ |
| PNG | .png | โ | โ | โ | โ |
| GIF | .gif | โ | โ | โ | โ |
| BMP | .bmp | โ | โ | โ | โ |
| TIFF | .tiff, .tif | โ | โ | โ | โ |
| WebP | .webp | โ | โ | โ | โ |
๐ Multi-language Font Support
Supported Languages
- Chinese: Simplified & Traditional Chinese
- Japanese: ใฒใใใชใใซใฟใซใใๆผขๅญ
- Korean: ํ๊ธ (Hangul)
- English: Latin character set
- Others: Most Unicode characters
Font Priority
macOS System:
- PingFang SC (Apple's default Chinese font)
- STHeiti Light (Chinese typography)
- Hiragino Sans GB (Winter Blue font)
- Arial Unicode (Universal Unicode font)
Windows System:
- Microsoft YaHei
- SimSun
- SimHei
Linux System:
- DejaVu Sans
- Liberation Sans
- Noto Sans CJK
- WenQuanYi Zen Hei
๐ Project Structure
stampit/
โโโ main.py # Main program and MCP server
โโโ pyproject.toml # Project configuration
โโโ README.md # English project documentation
โโโ README_CN.md # Chinese project documentation
โโโ uv.lock # Dependency lock file
โโโ LICENSE # License file
๐งช Quick Testing
Test Text Watermark
# 1. Start server
python main.py
# 2. Call in MCP client
add_text_watermark("path/to/your/image.jpg", "Test Watermark")
Test Image Watermark
# 1. Prepare a logo image
# 2. Call in MCP client
add_image_watermark("path/to/your/photo.jpg", "path/to/logo.png")
โ๏ธ Technical Details
Core Algorithms
- Brightness Calculation: Grayscale conversion + pixel average algorithm
- Color Adaptation: Four-tier classification system based on brightness thresholds
- Position Calculation: Staggered grid + edge offset algorithm
- Rendering Optimization: BICUBIC/LANCZOS resampling technology
Performance Optimization
- Font Caching: Avoid repeated font file loading
- Smart Scaling: Brightness calculation using 50x50 small images for speed
- Memory Management: Timely release of temporary layers and cache
- Batch Processing: Support for efficient batch image processing
Quality Assurance
- Edge Smoothing: Use high-quality resampling algorithms
- Color Fidelity: Preserve original image color space and mode
- Transparency Handling: Proper RGBA channel processing
- Format Compatibility: Smart conversion between different image formats
๐ง Advanced Configuration
You can adjust parameters by modifying the WatermarkConfig class:
class WatermarkConfig:
DEFAULT_FONT_SIZE = 36 # Default font size
DEFAULT_ANGLE = 30 # Default tilt angle
SPACING_X_FACTOR = 1.1 # Horizontal spacing multiplier
SPACING_Y_FACTOR = 0.9 # Vertical spacing multiplier
BRIGHTNESS_THRESHOLDS = { # Brightness thresholds
'very_bright': 180,
'medium': 120,
'dark': 60
}
Custom Parameter Suggestions
- Dense Watermarks: Lower spacing multipliers (0.8, 0.7)
- Sparse Watermarks: Higher spacing multipliers (1.5, 1.3)
- Large Fonts: Increase font size (48, 54)
- Small Fonts: Decrease font size (24, 30)
๐๏ธ Usage Tips
Text Watermark Tips
- Copyright Info: Use "ยฉ 2024 Company Name" format
- Multi-language: Mixed Chinese-English works better
- Angle Selection: 30ยฐ most natural, 45ยฐ more prominent, 0ยฐ for documents
Image Watermark Tips
- Logo Design: Use transparent background PNG format
- Size Control: Logo shouldn't be too large, recommend within 15% of original
- Color Matching: Choose logo colors with appropriate contrast to original image
๐ก Best Practices
Batch Processing Recommendations
# Recommended batch processing method
images = ["photo1.jpg", "photo2.jpg", "photo3.jpg"]
watermark_text = "ยฉ 2024 My Company"
for image_path in images:
result = add_text_watermark(image_path, watermark_text)
print(result)
Performance Optimization Suggestions
- Use same font size in batches to leverage font caching
- Avoid frequent angle changes to reduce computational overhead
- Use small-sized image watermarks to improve processing speed
๐ License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
๐ค Contributing
Issues and Pull Requests are welcome!
Contributing Guidelines
- Fork the project
- Create a feature branch
- Commit your changes
- Submit a Pull Request
๐ Technical Support
For questions or suggestions:
- Submit GitHub Issues
- Check project documentation
- Contact development team
๐ Thank you for using Stamp it!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netmind_mcp_stampit-1.0.3.tar.gz.
File metadata
- Download URL: netmind_mcp_stampit-1.0.3.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55930188222f1e78a1bdcec0a5057cffaefb9ac0a988e3810d357fe94516d57e
|
|
| MD5 |
eb9ec92dc0a0eba9522537e98233e561
|
|
| BLAKE2b-256 |
7e57f70fbba87ff81bfae4b32b1df18c54f448d0bc87ec93357a7fb118fa1407
|
File details
Details for the file netmind_mcp_stampit-1.0.3-py3-none-any.whl.
File metadata
- Download URL: netmind_mcp_stampit-1.0.3-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
907d1be0786ef6940268709d483dd201b046f8e0d327151786c3d615b3d3d2c5
|
|
| MD5 |
840a6f04b87ce3c05acb55600977fba7
|
|
| BLAKE2b-256 |
577fb80c29e3e6576e431542ad68d439fa419b43c8495006475087e844a932be
|