` | Inpaint radius for NS/TELEA/Soft, 1–25 (default: 10) |
**Region syntax:**
| Format | Description |
|--------|-------------|
| `x,y,w,h` | Absolute coordinates |
| `br:mx,my,w,h` | Bottom-right corner (margin_x, margin_y, width, height) |
| `bl:mx,my,w,h` | Bottom-left corner |
| `tr:mx,my,w,h` | Top-right corner |
| `tl:mx,my,w,h` | Top-left (same as absolute) |
| `br:auto` | Use Gemini default position based on image size |
**Examples:**
```bash
# Standard removal with AI denoise cleanup
GeminiWatermarkTool -i input.jpg -o clean.jpg --denoise ai
# Batch with AI denoise (all files)
GeminiWatermarkTool -i ./photos/ -o ./clean/ --denoise ai
# Fallback for images that fail detection: search bottom-right area with snap
GeminiWatermarkTool -i ./photos/ -o ./clean/ \
--fallback-region br:auto --snap --denoise ai
# Resized watermarks: expand snap search to 320px
GeminiWatermarkTool -i ./photos/ -o ./clean/ \
--fallback-region br:80,80,200,200 --snap --snap-max-size 320 --denoise ai
# Gemini preview images (small ~28px watermark): use lower snap-threshold
GeminiWatermarkTool -i preview.jpg -o clean.jpg \
--fallback-region br:auto --snap --snap-threshold 0.30 --denoise ai --sigma 13 --strength 175
# Force process at explicit region (all images have watermark at same spot)
GeminiWatermarkTool -i ./photos/ -o ./clean/ \
--force --region 500,800,160,160 --snap --denoise ai --sigma 75
```
> **Note:** When no `--denoise` is specified, the CLI behaves identically to previous versions (no cleanup pass). All existing scripts and agent integrations continue to work unchanged.
## Watermark Size Detection
The tool automatically detects the appropriate watermark size based on image dimensions:
| Image Size | Watermark | Position |
|------------|-----------|----------|
| W ≤ 1024 **or** H ≤ 1024 | 48×48 | Bottom-right, 32px margin |
| W > 1024 **and** H > 1024 | 96×96 | Bottom-right, 64px margin |
Use `--force-small` or `--force-large` to override automatic detection.
## System Requirements
| Platform | Requirements |
|----------|--------------|
| Windows | Windows 10/11 x64 |
| Linux | x64, glibc 2.35+ (Ubuntu 22.04+, Debian 12+) |
| macOS | macOS 11.0+ (Intel or Apple Silicon) |
| Android | ARM64, Android 10+ (API 29+) |
All binaries are statically linked with no external runtime dependencies.
> **AI Denoise** uses Vulkan for GPU acceleration. Most modern GPUs (NVIDIA, AMD, Intel) with up-to-date drivers support Vulkan. If no Vulkan GPU is detected, inference automatically falls back to CPU (OpenMP multi-threaded).
## Troubleshooting
### "The image doesn't look different after processing"
The watermark is semi-transparent. If the original background was similar to the watermark color, the difference may be subtle. Try viewing at 100% zoom in the watermark area (bottom-right corner).
### "Wrong watermark size detected"
Use `--force-small` or `--force-large` to manually specify:
```bash
GeminiWatermarkTool -i image.jpg -o output.jpg --force-small
```
### "File access denied"
Make sure the output path is writable and the file isn't open in another program.
## Limitations
- Only removes **Gemini visible watermarks** (the semi-transparent logo in bottom-right)
- Does **NOT** remove **SynthID invisible watermarks** — [see why](report/synthid_research.md)
- Designed for Gemini's current watermark pattern (as of 2025)
---
## Building from Source
### Prerequisites
| Tool | Version | Notes |
|------|---------|-------|
| CMake | 3.21+ | For CMakePresets support |
| C++ Compiler | C++20 | MSVC 2022, GCC 12+, Clang 14+ |
| vcpkg | Latest | Package manager |
| Ninja | Latest | Recommended build system |
### Setup vcpkg
```bash
# Clone vcpkg
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
# Bootstrap
./bootstrap-vcpkg.sh # Linux/macOS
.\bootstrap-vcpkg.bat # Windows
# Set environment variable
export VCPKG_ROOT="$HOME/vcpkg" # Linux/macOS (add to .bashrc)
$env:VCPKG_ROOT = "C:\vcpkg" # Windows PowerShell
```
### Build with CMake Presets
The project uses `CMakePresets.json` for cross-platform configuration.
```bash
# Clone with submodules (NCNN source)
git clone --recursive https://github.com/allenk/GeminiWatermarkTool.git
# Or if already cloned:
git submodule update --init --recursive
# List available presets
cmake --list-presets
```
#### Windows
```powershell
cmake --preset windows-x64-Release
cmake --build --preset windows-x64-Release
```
#### Linux
```bash
cmake --preset linux-x64-Release
cmake --build --preset linux-x64-Release
```
#### macOS (Universal Binary)
macOS requires separate builds for each architecture:
```bash
# Build x64
cmake -B build-x64 -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-osx \
-DCMAKE_OSX_ARCHITECTURES=x86_64
cmake --build build-x64
# Build arm64
cmake -B build-arm64 -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=arm64-osx \
-DCMAKE_OSX_ARCHITECTURES=arm64
cmake --build build-arm64
# Create Universal Binary
lipo -create build-x64/GeminiWatermarkTool build-arm64/GeminiWatermarkTool \
-output GeminiWatermarkTool
```
#### Android
Requires Android NDK:
```bash
export ANDROID_NDK_HOME="/path/to/android-ndk"
cmake --preset android-arm64-Release
cmake --build --preset android-arm64-Release
```
### Build Presets
| Preset | Platform | Backend | Notes |
|--------|----------|---------|-------|
| `windows-x64-Release` | Windows | D3D11 + OpenGL | Default, includes AI Denoise |
| `windows-x64-OpenGL-Release` | Windows | OpenGL only | Includes AI Denoise |
| `linux-x64-Release` | Linux | OpenGL | Includes AI Denoise |
| `mac-universal-Release` | macOS | OpenGL | Intel + Apple Silicon, includes AI Denoise |
| `android-arm64-Release` | Android | — | CLI only, includes AI Denoise |
All presets enable `ENABLE_AI_DENOISE=ON` by default. To build without AI, set `-DENABLE_AI_DENOISE=OFF` manually.
### Manual Build (without presets)
```bash
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-linux
cmake --build build
```
### Build — gwt-mini (minimal CLI)
For the published `gwt-mini` variant: GUI off, AI denoise on, no video pipeline.
```bash
# Linux
cmake -B build-mini -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_GUI=OFF \
-DENABLE_AI_DENOISE=ON \
-DENABLE_VIDEO=OFF \
-DVCPKG_MANIFEST_FEATURES="ai-denoise" \
-DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
cmake --build build-mini
strip build-mini/GeminiWatermarkTool
# Optional: shrink further with UPX
upx --best --lzma build-mini/GeminiWatermarkTool
```
On Windows add `-DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded`.
On macOS build x86_64 and arm64 separately, then `lipo -create` them into a universal binary
(same recipe as `mac-universal-Release`, just with the flags above).
---
## Project Structure
```
gemini-watermark-tool/
├── CMakeLists.txt # Main build configuration
├── CMakePresets.json # Cross-platform build presets
├── vcpkg.json # Dependencies manifest
├── src/
│ ├── core/ # Core engine (CLI + GUI shared)
│ │ ├── watermark_engine.hpp/cpp
│ │ ├── watermark_detector.hpp/cpp
│ │ ├── blend_modes.hpp/cpp
│ │ ├── ai_denoise.hpp/cpp # NCNN FDnCNN denoiser
│ │ ├── ai_denoise_model.cpp # Embedded model weights (isolated TU)
│ │ ├── ncnn_shim.hpp # Vulkan loader shim for NCNN
│ │ └── types.hpp
│ ├── cli/ # CLI application
│ │ └── cli_app.hpp/cpp
│ ├── utils/ # Utilities
│ │ ├── ascii_logo.hpp
│ │ └── path_formatter.hpp
│ ├── main.cpp # Entry point (CLI/GUI dispatcher)
│ └── gui/ # Desktop GUI (ImGui + SDL3)
│ ├── gui_app.hpp/cpp # GUI entry point
│ ├── app/
│ │ ├── app_state.hpp # Application state
│ │ └── app_controller.hpp/cpp # Logic controller
│ ├── widgets/
│ │ ├── main_window.hpp/cpp # Main window + menus
│ │ └── image_preview.hpp/cpp # Image viewer + batch view
│ ├── backend/
│ │ ├── render_backend.hpp/cpp # Backend interface + factory
│ │ ├── opengl_backend.hpp/cpp # OpenGL 3.3 implementation
│ │ └── d3d11_backend.hpp/cpp # Direct3D 11 implementation (Windows)
│ └── resources/
│ └── style.hpp # Theme and layout constants
├── external/
│ └── ncnn/ # NCNN source (git submodule)
│ └── model-convert/output/ # Converted FDnCNN model headers
├── report/
│ └── synthid_research.md # SynthID research documentation
└── resources/
├── app.ico # Windows application icon
└── app.rc.in # Windows resource template
```
## Dependencies
All dependencies are managed via vcpkg and statically linked:
| Package | Purpose |
|---------|---------|
| OpenCV | Image I/O and pixel operations |
| fmt | Modern string formatting |
| CLI11 | Command line argument parsing |
| spdlog | Logging framework |
| SDL3 | Window management and input (GUI) |
| Dear ImGui | Immediate mode GUI framework (GUI) |
| ImPlot | Plotting widgets (GUI) |
| glad | OpenGL loader (GUI) |
| nativefiledialog-extended | Native file dialogs (GUI) |
| WIL | Windows Implementation Libraries (D3D11 backend, Windows only) |
| NCNN | Neural network inference runtime (AI Denoise, git submodule) |
| volk | Vulkan meta-loader for dynamic dispatch (AI Denoise, vcpkg) |
---
## How It Works
### Gemini Watermark Analysis
Gemini applies visible watermarks using **alpha blending**:
```
watermarked = α × logo + (1 - α) × original
```
### Alpha Reconstruction
By statistically analyzing and comparing values related to Alpha, we can reconstruct an Alpha Map that is either correct or very close to it.
### Removal Algorithm (Reverse Alpha Blending)
Solving for the original pixel:
```
original = (watermarked - α × logo) / (1 - α)
= (watermarked - alpha_map) / (1 - α)
```
This mathematical inversion produces exact restoration of the original pixels.
### Residual Cleanup (Software Inpainting + AI Denoise)
When images have been resized or recompressed after watermarking, the exact math no longer holds perfectly. Two approaches are available for cleaning up residual artifacts:
**Software Inpainting** (NS / TELEA / Gaussian):
```
1. Compute gradient magnitude from watermark alpha channel
2. Build soft weight mask: stronger where alpha gradient is high
3. Apply selected inpainting method (NS / TELEA / Gaussian blend)
4. Blend result using weight mask — only affected pixels are modified
```
**AI Denoise** (FDnCNN, recommended):
```
1. Compute gradient mask from alpha map (locate sparkle edges)
2. Run FDnCNN inference on padded ROI (Vulkan GPU or CPU)
Input: [R, G, B, sigma/255] → Output: denoised clean image
3. Per-pixel masked blend: mask × denoised + (1-mask) × original
→ Only edge artifacts repaired, clean background untouched
```
---
## Legal Disclaimer
This tool is provided for **personal and educational use only**.
The removal of watermarks may have legal implications depending on your jurisdiction and the intended use of the images. Users are solely responsible for ensuring their use of this tool complies with applicable laws, terms of service, and intellectual property rights.
The author does not condone or encourage the misuse of this tool for copyright infringement, misrepresentation, or any other unlawful purposes.
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY ARISING FROM THE USE OF THIS SOFTWARE.**
## ❤️ Support This Project
If GeminiWatermarkTool saved you time and you'd like to help keep it going, you can support via [Ko-fi](https://ko-fi.com/allenkoss) or [PayPal](https://paypal.me/allenkoss) — both go to the same place; pick whichever works for you (a few users have reported Ko-fi checkout issues from their region, so PayPal is the dependable fallback). Every public release goes through GitHub Actions CI on Windows / Linux / macOS / Android, and the binaries live in the Releases section — small contributions help cover runner minutes and storage so the project can keep building cross-platform binaries for free. Not required, just appreciated.
Bug reports, sample images / videos, and pull requests remain the most valuable contributions and always will be — opening an [issue](https://github.com/allenk/GeminiWatermarkTool/issues) with content the tool can't handle is often more useful than a one-off donation.
## License
MIT License
## Author
**Allen Kuo** ([@allenk](https://github.com/allenk))
- GitHub: https://github.com/allenk
- LinkedIn: https://www.linkedin.com/in/allen-kuo-7b513a45/
- Medium: https://allenkuo.medium.com
**Quick start:**
```bash
# Install the integration (after GeminiWatermarkTool is on PATH)
git clone https://github.com/allenk/gwt-integrations.git
cd gwt-integrations
python install.py
```
After installation, AI agents can process watermarks conversationally:
```
"Remove the Gemini watermark from screenshot.png using AI denoise"
"Batch process all images in ./photos/ with fallback snap detection"
```
See [gwt-integrations README](https://github.com/allenk/gwt-integrations) for full setup instructions and MCP configuration.
## Related
- [Removing Gemini AI Watermarks: A Deep Dive into Reverse Alpha Blending](https://allenkuo.medium.com/removing-gemini-ai-watermarks-a-deep-dive-into-reverse-alpha-blending-bbbd83af2a3f)
- [SynthID Image Watermark Research Report](https://allenkuo.medium.com/synthid-image-watermark-research-report-9b864b19f9cf)
- [SynthID Research Report](report/synthid_research.md) — Why invisible watermarks cannot be removed
- [gwt-integrations](https://github.com/allenk/gwt-integrations) — Claude Code Skill + MCP Server for AI agent automation
## Third-Party Licenses
This project incorporates the following open-source components:
| Component | License | Usage |
|-----------|---------|-------|
| [NCNN](https://github.com/Tencent/ncnn) | BSD-3-Clause | Neural network inference runtime (Vulkan GPU + CPU) |
| [FDnCNN model weights](https://github.com/cszn/KAIR) (KAIR) | MIT | Pre-trained denoising model (embedded FP16 weights) |
| [volk](https://github.com/zeux/volk) | MIT | Vulkan meta-loader for dynamic dispatch |
Full license texts for these components are available in their respective repositories.
---
If this tool helped you, consider giving it a ⭐