gemwm
Go library for removing visible watermarks from Google Gemini AI-generated images.
Gemini adds a semi-transparent star (✦) watermark to the bottom-right corner of generated images. This library removes it using mathematically precise Reverse Alpha Blending — no AI, no inpainting, just math.
Note: This tool only removes the visible watermark. It does NOT remove SynthID (Google's invisible watermark).
Install
go get github.com/BlakeLiAFK/gemwm
Usage
Library
package main
import (
"log"
"github.com/BlakeLiAFK/gemwm"
)
func main() {
img, _ := gemwm.LoadImage("input.png")
// One function, that's it
result, err := gemwm.Clean(img)
if err != nil {
log.Fatal(err)
}
if result.Detected {
gemwm.SaveImage("output.png", result.Image)
}
}
Options
// Force remove (skip detection)
result, _ := gemwm.Clean(img, gemwm.WithForce())
// Custom detection threshold (default: 0.35)
result, _ := gemwm.Clean(img, gemwm.WithThreshold(0.5))
// Force specific mask size (48 or 96)
result, _ := gemwm.Clean(img, gemwm.WithMaskSize(96))
// File shortcut
err := gemwm.CleanFile("input.png", "output.png")
CLI
go install github.com/BlakeLiAFK/gemwm/cmd/gemwm@latest
# Single file
gemwm photo.png -o clean.png
# Force mode
gemwm photo.png -o clean.png --force
# Batch
gemwm ./input/ -o ./output/ --batch
# Verbose
gemwm photo.png -o clean.png -v
How It Works
Gemini applies visible watermarks using alpha compositing:
watermarked = alpha * 255 + (1 - alpha) * original
We reverse the formula to recover original pixels:
original = (watermarked - alpha * 255) / (1 - alpha)
The alpha map is pre-calibrated from known Gemini watermark templates (48x48 and 96x96).
Watermark Specs
| Image Size |
Watermark |
Margin |
| Either dim <= 1024px |
48x48 |
32px |
| Both dims > 1024px |
96x96 |
64px |
Detection
Three-stage weighted detection (NCC-based):
| Stage |
Method |
Weight |
| Spatial NCC |
Pattern correlation |
50% |
| Gradient NCC |
Sobel edge matching |
30% |
| Variance Analysis |
Texture dampening |
20% |
Default threshold: 0.35
Result
type Result struct {
Image image.Image // Processed image
Detected bool // Watermark detected
Confidence float64 // Detection confidence (0.0-1.0)
MaskSize int // Mask size used (48 or 96)
}
License
MIT