ComfyUI Extension: Blind_watermark_Comfyui
A powerful blind watermark plugin for ComfyUI that allows you to embed and extract invisible watermarks in images using frequency domain techniques (DWT-DCT-SVD).
Custom Nodes (0)
README
ComfyUI Blind Watermark
A powerful blind watermark plugin for ComfyUI that allows you to embed and extract invisible watermarks in images using frequency domain techniques (DWT-DCT-SVD).
This project is based on https://github.com/guofei9987/blind_watermark.git Production, thank you for the big shot's open source
Features
- π Invisible Watermarks: Embed watermarks that are imperceptible to the human eye
- π Text Watermarks: Embed and extract text messages
- πΌοΈ Image Watermarks: Embed and extract image watermarks
- π² QR Code Support: Generate and decode QR codes for advanced watermarking
- π‘οΈ Robust: Resistant to common image manipulations (rotation, cropping, scaling, compression)
- βοΈ Advanced Controls: Fine-tune embedding strength, DCT coefficients, and processing modes
- π¨ ComfyUI Integration: Seamless workflow integration with native node support
Installation
1. Install the Plugin
Navigate to your ComfyUI custom nodes directory and clone this repository:
cd ComfyUI/custom_nodes
git clone https://github.com/TianDongL/Blind_watermark_Comfyui.git
2. Install Dependencies
Install the required Python packages:
cd Comfyui_blind_watermark
pip install -r requirements.txt
Required packages:
blind-watermark- Core watermarking libraryqrcode- QR code generationpillow- Image processingpyzbar(optional) - QR code decoding
3. Restart ComfyUI
Restart ComfyUI to load the new nodes.
Available Nodes
Watermark Nodes
-
π Embed Text Watermark
- Embeds invisible text into images
- Configurable embedding strength (d1, d2)
- Supports multiple DCT coefficient modes
-
π Extract Text Watermark
- Extracts embedded text from watermarked images
- Requires matching password and length parameters
- Provides detailed extraction info
-
πΌοΈ Embed Image Watermark
- Embeds an invisible image watermark into another image
- Supports PNG, JPEG, and other formats
- Configurable alpha blending
-
π Extract Image Watermark
- Extracts embedded image watermarks
- Requires watermark dimensions (width Γ height)
- Outputs extracted watermark as image tensor
QR Code Nodes
-
π² Generate QR Code
- Creates QR codes from text/URLs
- Adjustable size and error correction levels
- Outputs as image tensor for further processing
-
π Decode QR Code
- Decodes QR codes from images
- Automatic detection and extraction
- Returns decoded text/URL
Quick Start Guide
Example 1: Text Watermark Workflow
Embed Text:
- Load your image using "Load Image" node
- Add "π Embed Text Watermark" node
- Connect the image and enter:
- Watermark Text: "Copyright 2025"
- Password: 12345
- d1/d2: Use defaults (36/20) or adjust
- Save the watermarked image
Extract Text:
- Load the watermarked image
- Add "π Extract Text Watermark" node
- Enter the same password and text length
- View extracted text in output
Example 2: Image Watermark Workflow
Embed Image:
- Load the original image
- Load your watermark/logo image
- Add "πΌοΈ Embed Image Watermark" node
- Connect both images
- Set password and embedding strength
- Save the result
Extract Image:
- Load the watermarked image
- Add "π Extract Image Watermark" node
- Enter password and watermark dimensions
- View extracted watermark
Example 3: QR Code Watermark
- Generate a QR code with "π² Generate QR Code"
- Use it as watermark with "πΌοΈ Embed Image Watermark"
- Extract and decode with "π Extract Image Watermark" β "π Decode QR Code"
Parameters Explained
Password Parameters
- password_img: Password for image encryption (integer)
- password_wm: Password for watermark encryption (integer)
- Both passwords must match between embed and extract operations
Embedding Strength (d1/d2)
- d1: Controls frequency coefficient range (default: 36)
- d2: Controls embedding strength (default: 20)
- Higher values = stronger watermark, more visible
- Lower values = weaker watermark, more invisible
- Recommended: d1=36, d2=20 for balanced results
DCT Coefficient Modes
- Mode 1: Uses fewer coefficients (faster, less robust)
- Mode 2: Uses more coefficients (slower, more robust)
- Mode 3: Uses even more coefficients (slowest, most robust)
Processing Modes
- Single Process: Standard processing
- Multi-core: Parallel processing for faster embedding
- All Cores: Uses all available CPU cores
Watermark Robustness
This watermark technique is resistant to:
| Attack Type | Robustness | Notes | |------------|-----------|--------| | π Rotation | ββββ | Survives moderate rotation | | βοΈ Cropping | βββββ | Highly resistant | | π Scaling | βββββ | Survives resize operations | | π Masking | ββββ | Partial watermark still recoverable | | π¦ Compression | ββββ | Survives JPEG compression | | π Brightness/Contrast | βββββ | Unaffected by color adjustments | | π Noise | βββ | Moderate resistance |
Tips & Best Practices
For Best Results:
-
Password Management
- Use the same passwords for embedding and extraction
- Record passwords securely
- Higher passwords = more security
-
Watermark Length
- Keep text watermarks concise (< 100 characters)
- Longer watermarks require larger images
- Note the reported
wm_bit_lengthafter embedding
-
Image Quality
- Use high-resolution images (minimum 512Γ512)
- Avoid heavily compressed images as input
- Save watermarked images in lossless formats (PNG)
-
Embedding Strength
- Start with defaults (d1=36, d2=20)
- Increase d2 if extraction fails
- Decrease d2 if watermark is visible
-
Image Watermarks
- Use simple, high-contrast watermark images
- Recommended watermark size: 64Γ64 or 128Γ128
- Black and white logos work best
Troubleshooting
Watermark Extraction Failed
Problem: Extracted text is garbled or empty
Solutions:
- β Verify passwords match exactly
- β
Check
wm_bit_lengthparameter - β Ensure image hasn't been re-encoded multiple times
- β Try increasing embedding strength (d2)
- β Use the same DCT mode for embed/extract
Watermark Visible in Image
Problem: Watermark creates visible artifacts
Solutions:
- β Reduce d2 parameter (e.g., from 20 to 15)
- β Use a smaller watermark
- β Ensure input image is high quality
Node Not Appearing
Problem: Nodes don't show up in ComfyUI
Solutions:
- β
Check
requirements.txtpackages are installed - β Restart ComfyUI completely
- β Check console for error messages
- β
Verify folder is in
ComfyUI/custom_nodes/
Technical Details
This plugin uses frequency domain watermarking based on:
- DWT (Discrete Wavelet Transform)
- DCT (Discrete Cosine Transform)
- SVD (Singular Value Decomposition)
The watermark is embedded in the frequency domain, making it invisible to the human eye while being detectable with the correct password.
Credits
Based on the excellent blind_watermark library by @guofei9987.
Related Projects
- blind_watermark: https://github.com/guofei9987/blind_watermark
- Text Blind Watermark: https://github.com/guofei9987/text_blind_watermark
- HideInfo: https://github.com/guofei9987/HideInfo
License
This project follows the original blind_watermark library license. Please refer to the LICENSE file for details.
Support & Contribution
- π Bug Reports: Open an issue on GitHub
- π‘ Feature Requests: Open an issue with your suggestion
- π§ Pull Requests: Contributions are welcome!
Happy Watermarking! π¨π