Lossless Gemini Watermark Removal with Reverse Alpha Blending
Gemini stamps every generated image with a sparkle watermark. Most people crop it. This open-source agent skill algebraically undoes it — pixel-perfect, in under a second.
The video version · same thesis, looser edits
The watermark nobody asked for
Every image Google Gemini generates ships with a semi-transparent sparkle logo composited into the bottom-right corner. It’s not metadata. It’s not steganography. It’s pixels — white pixels alpha-blended directly onto your output.
If you’ve been cropping it, blurring it, or feeding it to an inpainting model, you’ve been destroying image data to remove something that was mathematically applied. That means it can be mathematically reversed.
This agent skill does exactly that. One Python script, two NumPy alpha maps, and a formula you can derive on a whiteboard.
Why this isn’t inpainting
Inpainting guesses what used to be there. Reverse alpha blending calculates what used to be there. The distinction matters.
Gemini’s watermark uses standard alpha compositing — the same formula that every compositor, browser, and GPU blending pipeline uses:
watermarked_pixel = α × 255 + (1 − α) × original_pixel
The watermark color is pure white (255). The alpha values are fixed for each pixel in the sparkle logo. Both are known constants. The only unknown is the original pixel value, and it solves out in one line of algebra:
original_pixel = (watermarked_pixel − α × 255) / (1 − α)
No neural network. No training data. No hallucinated texture. The original pixel value is recovered exactly, with zero information loss.
How the multi-pass engine works
A single pass of reverse alpha blending handles most images. But some watermarks — particularly on darker backgrounds where the white sparkle has higher visual contrast — require iterative refinement.
The script runs up to four passes. After each pass, it computes the normalized cross-correlation (NCC) between the processed region and the expected alpha pattern. When the correlation drops below 0.25, the watermark signal is gone and the loop terminates.
There’s also a safety check: if the near-black pixel ratio in the watermark region spikes beyond baseline + 50%, the script stops to prevent over-correction on areas that were already dark.
def remove_watermark_pass(img_array, alpha_map, x, y, size, alpha_gain=1.0):
"""Perform reverse alpha blending to remove the watermark layer."""
result = img_array.copy()
region = result[y:y+size, x:x+size, 0:3].astype(np.float32)
denoised_alpha = np.maximum(0, alpha_map - ALPHA_NOISE_FLOOR) * alpha_gain
active_mask = denoised_alpha >= ALPHA_THRESHOLD
alpha = np.minimum(alpha_map * alpha_gain, MAX_ALPHA)
one_minus_alpha = 1.0 - alpha
for c in range(3):
watermarked = region[:,:,c]
original = (watermarked - alpha * LOGO_VALUE) / one_minus_alpha
region[:,:,c] = np.where(
active_mask,
np.clip(np.round(original), 0, 255),
watermarked
)
result[y:y+size, x:x+size, 0:3] = region.astype(np.uint8)
return result
The ALPHA_NOISE_FLOOR constant (3/255) strips sub-pixel alpha noise from the map edges, and MAX_ALPHA caps at 0.99 to prevent division-by-zero on fully opaque pixels. These aren’t arbitrary — they’re calibrated against Gemini’s actual compositing behavior.
The alpha maps are the secret
The math is trivial. The hard part is knowing the exact alpha values Gemini uses for each pixel position in the sparkle logo.
The skill ships with two pre-calculated NumPy arrays:
| File | Dimensions | Used for |
|---|---|---|
alpha_48.npy | 48 × 48 | 0.5k-tier outputs (512×512 and smaller aspect ratios) |
alpha_96.npy | 96 × 96 | 1k, 2k, and 4k-tier outputs (1024×1024 and up) |
Without these exact maps, the formula has no alpha values to invert. You’d be guessing — which is what inpainting does, and why it produces artifacts.
The script auto-detects which map to use by matching the input image dimensions against Gemini’s known output size catalog (15 aspect ratios per tier), then falls back to a heuristic for non-standard sizes.
Setting it up
Requirements
Python 3, NumPy, and Pillow. That’s the entire dependency tree.
pip install numpy Pillow
Installation
Drop the skill folder into your agent workspace’s skills directory:
your-workspace/
skills/
gemini_watermark_remover/
SKILL.md
scripts/
remove_watermark.py
alpha_maps/
alpha_48.npy
alpha_96.npy
resources/
algorithm.md
examples/
usage.md
The SKILL.md file tells your agent what this tool does, when to invoke it, and how to interpret the output. Any agent that reads skill files — including Antigravity — will pick this up automatically.
Direct usage
You don’t need an agent to run it. The script works standalone:
python scripts/remove_watermark.py my_gemini_image.png --output clean.png
Output:
Removed watermark successfully in 1 passes (residual-low).
Output saved to: clean.png
For programmatic integration, the --json flag returns structured metadata:
python scripts/remove_watermark.py my_gemini_image.png --json
{
"applied": true,
"file": "my_gemini_image_clean.png",
"decision": {
"logo_size": 96,
"margin_right": 64,
"margin_bottom": 64
},
"initial_score": 0.589,
"passes_applied": 1,
"stop_reason": "residual-low"
}
If no watermark is detected (NCC score below 0.2), the script exits cleanly with "applied": false and doesn’t modify the image.
What this does NOT do
This skill removes the visible sparkle watermark — the composited pixel overlay in the bottom-right corner of Gemini images.
It does not remove, alter, or interfere with Google’s SynthID — the invisible steganographic watermark embedded in the frequency domain of Gemini-generated images. SynthID is designed for AI provenance tracking and is undetectable to the human eye. The reverse alpha blending process operates exclusively on the RGB pixel values in the watermark region and has no effect on frequency-domain metadata.
The source
The full skill is open-source under Apache 2.0:
GitHub: github.com/useaitechdad/agent-skills
Clone the repo, drop the gemini_watermark_remover_agent_skill folder into your workflow, and stop manually cropping watermarks.
- Lossless Gemini Watermark Removal with Reverse Alpha Blending
- Free Python Script: Auto-Generate High-SEO SRT Files