watermark-removal
npx skills add https://github.com/horace4444/extend-my-claude-code --skill watermark-removal
Agent 安装分布
Skill 文档
Universal Watermark Removal
Remove watermarks from ANY image source using intelligent detection and proven methods. Smart routing: automatically detects Google SynthID and uses the proven aggressive method, falls back to ML inpainting for unknown watermark types.
Quick Start
Single Image – Smart Auto-Detection (Recommended)
# Smart detection: Google SynthID â aggressive method (proven), Unknown â inpaint (ML)
python .claude/skills/watermark-removal/scripts/remove-watermark.py \
input.png \
output.png
Single Image – Preserve Dimensions (Force ML)
# Force ML inpainting even for Google SynthID (preserves exact dimensions)
python .claude/skills/watermark-removal/scripts/remove-watermark.py \
input.png \
output.png \
--method inpaint
Batch Processing (Get User Approval First!)
â ï¸ IMPORTANT: Always ask user before batch processing, especially with crop/aggressive methods that alter dimensions.
# Recommended: Preserves dimensions
python .claude/skills/watermark-removal/scripts/batch-process.py \
/path/to/input-dir \
/path/to/output-dir \
--method inpaint
# Alternative: Fast but crops 120px (requires user approval)
python .claude/skills/watermark-removal/scripts/batch-process.py \
/path/to/input-dir \
/path/to/output-dir \
--method aggressive
Smart Detection System â NEW
The skill automatically detects Google SynthID watermarks and routes to the optimal removal method:
Google SynthID Detection
Characteristics analyzed:
- RGBA mode (PNG format with alpha channel)
- Large dimensions (>1500px width and height)
- Typical Google AI aspect ratios (1.83, 1.0, 1.5, 1.78 with 10% tolerance)
- Automatic corner detection for watermark location
Smart routing logic:
-
If Google SynthID detected â Uses
aggressivemethod (proven to work perfectly)- Crops 120px from detected corner
- Removes alpha channel watermarking
- Paints over any remnants
- Works 100% reliably on Google AI images
-
If unknown/other watermark â Uses
inpaintmethod (ML-based)- Preserves exact dimensions
- Uses OpenCV Navier-Stokes algorithm
- Works on any watermark type
Override Default Behavior
# Force ML inpainting even for Google SynthID (preserves dimensions)
python scripts/remove-watermark.py input.png output.png --method inpaint
# Force aggressive method for non-Google watermarks
python scripts/remove-watermark.py input.png output.png --method aggressive
# Disable auto-detection (assume bottom-right corner)
python scripts/remove-watermark.py input.png output.png --no-detect
Methods
Inpaint Method (Best Quality) â NEW
What it does: ML-based inpainting with automatic watermark detection
Features:
- Automatically detects watermark location (any corner)
- Uses OpenCV’s Navier-Stokes inpainting algorithm
- Intelligently fills watermark area with surrounding patterns
- Works on ANY watermark type (not just Google SynthID)
Pros:
- Highest quality results
- Preserves exact dimensions
- Works on watermarks in any corner
- Handles complex backgrounds intelligently
- Universal – works on all watermark types
Cons:
- Requires OpenCV installation (
pip install opencv-python) - Slightly slower than crop method
- May need parameter tuning for very large watermarks
Use when:
- You need the best possible quality
- Watermark is on complex/detailed background
- Preserving exact dimensions is critical
- Working with non-Google watermarks
Aggressive Method (Fast & Reliable)
What it does: Auto-detects corner, crops 120px, removes alpha channel, paints remnants
Pros:
- Fast and reliable
- Automatic detection of watermark corner
- Handles RGBA images properly
- Good for batch processing
Cons:
- Reduces image size by 120px
- May crop content near edges
Use when:
- Processing many images quickly (default for batch)
- Size reduction is acceptable
- Google SynthID watermarks
Crop Method
What it does: Auto-detects and crops watermark corner
Pros:
- Fastest method
- Automatic detection
- Minimal processing
Cons:
- May leave watermark remnants
- Doesn’t handle alpha channel watermarking
Use when:
- Speed is top priority
- Quick preview needed
Paint Method
What it does: Paints over watermark without cropping (no auto-detection)
Pros:
- Preserves dimensions
- Simple approach
Cons:
- Assumes bottom-right corner only
- May leave visible artifacts
- Less reliable than inpaint
Use when:
- Simple watermarks on solid backgrounds
- Legacy compatibility
Important Guidelines
Dimension Preservation Priority
BALANCE DOMAIN KNOWLEDGE WITH DIMENSION PRESERVATION
-
Smart default behavior:
- Google SynthID detected â
aggressivemethod (proven perfect, crops 120px) - Unknown watermark â
inpaintmethod (preserves dimensions)
- Google SynthID detected â
-
User override available:
- Force dimension preservation with
--method inpaintflag - Force cropping with
--method aggressiveflag
- Force dimension preservation with
-
User approval required for batch cropping:
- If processing multiple Google SynthID images with aggressive method
- Explain that method will reduce image size by 120px
- Get explicit confirmation
- Show before/after dimensions
Batch Processing Protocol
NEVER start batch processing without user confirmation:
-
Show what will happen:
- Number of images to process
- Method to be used
- Whether dimensions will be preserved or altered
-
Get explicit approval:
- “I will process X images using [method]. This [will/will not] alter dimensions. Proceed?”
-
Prefer non-destructive:
- Default to
inpaintfor batch processing - Only use
aggressiveif user specifically requests speed over quality
- Default to
Workflow
1. Identify Watermarked Images
Common watermark types:
- Google SynthID: Small star/sparkle icon in corner
- Stock photos: Logo or text overlay
- AI services: Corner badges (Midjourney, DALL-E)
- Camera watermarks: Date/time stamps
2. Choose Method
Smart Default Workflow (NEW):
- Run script without –method flag – Smart detection automatically routes to best method
- Google SynthID detected â Uses
aggressivemethod (proven perfect) - Unknown watermark â Uses
inpaintmethod (ML-based, preserves dimensions) - Override with –method flag if needed
Method Selection Guide:
- Smart auto (recommended): No flag (detects Google SynthID â aggressive, else â inpaint)
- Force dimension preservation:
--method inpaint(ML-based, works on any watermark) - Force Google method:
--method aggressive(crops 120px, perfect for SynthID) - Maximum speed:
--method crop(fastest, crops but may leave remnants) - Legacy:
--method paint(basic, preserves dimensions but less reliable)
3. Process Images
Smart auto-detection (recommended):
python scripts/remove-watermark.py input.png output.png
Force dimension preservation:
python scripts/remove-watermark.py input.png output.png --method inpaint
Fast batch processing:
python scripts/batch-process.py ./input ./output --method aggressive
Disable auto-detection (force bottom-right):
python scripts/remove-watermark.py input.png output.png --method inpaint --no-detect
4. Verify Results
- Check output images for clean corners
- Verify no important content was cropped
- Confirm watermark fully removed
Command Reference
remove-watermark.py
python scripts/remove-watermark.py INPUT OUTPUT [OPTIONS]
Arguments:
INPUT Input image path
OUTPUT Output image path
Options:
--method {crop|inpaint} Removal method (default: crop)
--size INT Watermark size in pixels (default: 60)
batch-process.py
python scripts/batch-process.py INPUT_DIR OUTPUT_DIR [OPTIONS]
Arguments:
INPUT_DIR Directory with images to process
OUTPUT_DIR Directory for cleaned images
Options:
--method {crop|inpaint} Removal method (default: crop)
--pattern PATTERN File pattern to match (default: *.png)
--size INT Watermark size in pixels (default: 60)
Examples
Example 1: Website Images
Scenario: User has 3 Google AI images for website, watermarks need removal
# Batch process all PNG images
python scripts/batch-process.py \
./public/images \
./public/images-clean \
--method crop \
--pattern "*.png"
Output:
Found 3 images to process
Input: ./public/images
Output: ./public/images-clean
Method: crop
[1/3] Processing: ad-design-bedroom.png
â
Saved to: ad-design-bedroom.png
[2/3] Processing: ad-design-kitchen.png
â
Saved to: ad-design-kitchen.png
[3/3] Processing: ad-designs-bathroom.png
â
Saved to: ad-designs-bathroom.png
â
Successfully processed: 3/3
Example 2: Preserve Exact Dimensions
Scenario: Client needs exact 1920×1080 image, can’t crop
python scripts/remove-watermark.py \
hero-image.png \
hero-image-clean.png \
--method inpaint
Example 3: Larger Watermark
Scenario: Watermark is bigger than usual (70px)
python scripts/batch-process.py \
./images \
./images-clean \
--method crop \
--size 70
Technical Details
See references/synthid-watermark.md for:
- SynthID watermark specifications
- Method comparison details
- Edge cases and considerations
- Legal/ethical guidelines
Dependencies
Required:
- Python 3.7+
- Pillow (PIL):
pip install Pillow - NumPy:
pip install numpy
Optional (for ML inpainting):
- OpenCV:
pip install opencv-python
Install all dependencies:
pip install Pillow numpy opencv-python
Note: The inpaint method requires OpenCV. Other methods work without it.
Tips
Performance:
- Crop method is 5-10x faster than inpaint
- For 100+ images, use crop method
Quality:
- Save with quality=95 to minimize compression
- PNG format preserves quality better than JPEG
Backup:
- Always keep original watermarked images
- Process copies, not originals
Testing:
- Test on one image before batch processing
- Verify watermark size with
--sizeflag if needed