How Gemini Alpha Blending Watermarks Work (and How to Reverse Them)
The Only AI Watermark You Can Mathematically Undo
Most watermarks are burned into the image — pixels are overwritten, information is destroyed, and removal is a guessing game. Gemini's visible ✦ sparkle watermark is different. It's applied through alpha blending, a compositing operation that mixes the watermark into the original image using a transparency map. Because the blend follows a known formula and Google uses a fixed alpha template, the process can be reversed with exact arithmetic — no AI inpainting, no guessing, no quality loss.
This article breaks down exactly how the watermark is applied, the math that reverses it, the template parameters, and the edge cases where the reversal isn't perfect.
How Alpha Blending Works
Alpha blending is the standard compositing operation used everywhere from Photoshop layers to video game rendering. The formula for blending a foreground onto a background is:
composited = original × (1 - α) + watermark × α Where:
- original — the pixel value in the clean image (what we want to recover)
- watermark — the pixel value of the watermark overlay (white, so 255 for all three RGB channels)
- α (alpha) — the opacity at this pixel, ranging from 0.0 (fully transparent) to 1.0 (fully opaque)
- composited — the final pixel value in the watermarked image (what we can see)
Since the Gemini sparkle is white, the formula simplifies to:
composited = original × (1 - α) + 255 × α At pixels where α = 0, the composited value equals the original — no watermark is present. Where α is high (approaching 1.0), the pixel is pushed toward pure white regardless of what the original was. The sparkle glyph is defined entirely by the spatial distribution of α values — the alpha template.
The Reversal Formula
Because we know the watermark color (white = 255) and we have the alpha template (a fixed PNG file), we can solve the compositing equation for the original pixel value:
original = (composited - α × 255) / (1 - α) This is simple algebra — rearrange the blend equation, isolate the unknown. The result is clamped to [0, 255] to stay within valid color range:
restored = Math.max(0, Math.min(255, Math.round(
(composited - α × 255) / (1 - α)
))) This is the actual formula used in our engine (public/engines/gemini.js, line 48). It runs per-pixel, per-channel (R, G, B independently), for every pixel where the alpha template has a non-zero value.
Why This Is Lossless (in Theory)
The reversal is the exact mathematical inverse of the blending operation. If the watermarked image hasn't been recompressed, resized, or screenshotted since Gemini generated it, the restored pixel values are identical to the originals — bit-for-bit recovery. No neural network, no hallucinated pixels, no blurring.
In practice, there are two sources of small errors (covered in the edge cases section below), but for the vast majority of images the result is indistinguishable from the original.
The Alpha Template
The sparkle shape is encoded in an alpha template — a grayscale PNG where brightness represents opacity. Our engine uses two template sizes based on the image dimensions:
| Template | Size | Margin (right) | Margin (bottom) | Used When |
|---|---|---|---|---|
gemini_bg_48.png | 48 × 48 px | 32 px | 32 px | min(width, height) ≤ 1024 |
gemini_bg_96.png | 96 × 96 px | 64 px | 64 px | min(width, height) > 1024 |
The decision logic (getConfig in the engine) checks the shorter dimension of the image. Small images (up to 1024px on their shortest side) get the 48px template with 32px margins. Larger images get the 96px template with 64px margins. The template is positioned at:
x = imageWidth - marginRight - templateSize
y = imageHeight - marginBottom - templateSize The alpha template itself is loaded from the PNG and converted to a Float32Array. Each pixel's opacity is computed as the maximum of its R, G, B channels divided by 255:
alpha[i] = Math.max(R, G, B) / 255 Threshold and Clamping Constants
Two constants control the reversal precision:
ALPHA_THRESHOLD = 0.002— pixels with alpha below this are skipped entirely. They're effectively transparent and modifying them would introduce rounding noise without visible benefit.MAX_ALPHA = 0.99— alpha values are clamped to this maximum before the division. Without this, an alpha of exactly 1.0 would cause division by zero (1 - 1.0 = 0), and values very close to 1.0 would cause extreme amplification that blows out the recovered pixel. Clamping to 0.99 means the divisor is at least 0.01.
Standard Gemini Image Sizes
Gemini generates images at a fixed set of resolutions. The alpha reversal works perfectly on these because the template placement matches exactly:
| Resolution | Aspect Ratio | Template Used |
|---|---|---|
| 1024 × 1024 | 1:1 | 48px (min dim = 1024) |
| 1536 × 1024 | 3:2 | 48px (min dim = 1024) |
| 1024 × 1536 | 2:3 | 48px (min dim = 1024) |
| 2816 × 1536 | ~16:9 | 96px (min dim = 1536) |
| 1536 × 2816 | ~9:16 | 96px (min dim = 1536) |
If you upload a Gemini image at its native resolution — which is the default unless you've resized it — the alpha reversal recovers the original pixels with mathematical precision.
Non-Standard Sizes: The Inpainting Fallback
When an image doesn't match a standard Gemini size (because it was cropped, resized, or screenshotted), the alpha template may not align correctly with the actual sparkle position. In this case, the engine falls back to a different approach:
- Sparkle detection — a connected-component search scans the bottom-right corner of the image for bright clusters (grayscale ≥ 70). It filters by area (50–800 pixels) and aspect ratio (roughly square), then scores candidates by size and proximity to the corner.
- Inpainting — once the sparkle center is located, an 80×80 region around it is processed. Each bright pixel is replaced by the average color of its dark neighbors (sampled from 8 directions with a margin of 8 pixels). This is a simple neighborhood-average fill, not AI inpainting.
The inpainting fallback is lossy — it approximates the original rather than recovering it exactly. But it handles arbitrary image sizes where the template-based reversal can't be applied.
Edge Cases and Limitations
Dark Backgrounds and Alpha Amplification
The reversal formula divides by (1 - α). When α is high (the sparkle is very opaque at that pixel), the divisor is small, which amplifies any error in the composited value. On a very dark background (original near 0), the composited value is approximately α × 255. The reversal computes:
(α × 255 - α × 255) / (1 - α) = 0 / (1 - α) = 0 ✓ correct This works perfectly in theory. In practice, JPEG compression may have shifted the composited value by ±1 or ±2. With a small divisor, that tiny error gets amplified:
(α × 255 + 2 - α × 255) / (1 - α) = 2 / 0.01 = 200 ✗ should be ~0 This is why the MAX_ALPHA clamp exists — it prevents the divisor from getting smaller than 0.01, limiting the maximum amplification to 100×. For most images this is sufficient, but on very dark backgrounds with heavy JPEG compression, you may see faint bright artifacts where the sparkle was.
JPEG Compression Artifacts
If the Gemini image was saved as JPEG (either by Gemini or by the user), compression introduces block-level rounding errors. The reversal formula assumes the composited values are exact, so these errors propagate into the restored pixels. The effect is usually invisible on light or medium backgrounds, but can produce subtle color shifts in the watermark region on dark images.
Recommendation: if you have a choice, work with PNG exports from Gemini. The reversal on an uncompressed PNG is truly lossless.
Resized or Screenshotted Images
If the image has been resized after Gemini generated it, the sparkle is no longer at the expected pixel coordinates and the alpha template doesn't align. The engine detects this mismatch and falls back to inpainting rather than applying a misaligned reversal (which would create white artifacts in the wrong location).
Why Alpha Reversal Beats AI Inpainting
| Property | Alpha Reversal | AI Inpainting |
|---|---|---|
| Accuracy | Mathematical exact (per-pixel) | Approximate (hallucinated pixels) |
| Speed | Instant (~1ms for 96×96 region) | Seconds to minutes (GPU-dependent) |
| Quality loss | None (on PNG/original resolution) | Always some — textures, edges blurred |
| Works on text | Yes — recovers exact letterforms | Often smears or invents characters |
| Privacy | Runs in browser, no upload | Many tools require server upload |
| Requires | Known alpha template | Trained neural network |
Alpha reversal is the optimal approach when it's applicable — when you have the original-resolution Gemini image and the correct alpha template. For resized or screenshotted images, our engine automatically falls back to the simpler neighborhood-average fill, which is still faster and more private than server-based AI inpainting.
Try the alpha reversal on your Gemini images
Reverse Gemini Watermarks — FreeFrequently Asked Questions
Does this also remove SynthID (the invisible watermark)?
No. Alpha reversal only removes the visible sparkle ✦. SynthID is a separate invisible watermark embedded in the pixel data at the signal level — it survives any image transformation including alpha reversal. Our tool removes what you can see; SynthID stays. For most uses this doesn't matter, since SynthID is undetectable without specialized Google software.
Will this work on a screenshot of a Gemini image?
The alpha reversal won't, because the screenshot changes the resolution and pixel alignment. The engine will automatically fall back to inpainting mode, which still removes the sparkle but with slightly lower quality (approximated rather than exact).
Can I verify the reversal is lossless?
Yes — if you have the original un-watermarked version (e.g., from a paid Gemini plan), you can compare pixel values. On an uncompressed PNG at native resolution, the reversed image will match the original within ±1 per channel (rounding). On JPEG, the difference will be slightly larger in the sparkle region due to compression artifacts, but indistinguishable to the human eye.
Ready to remove your NotebookLM watermarks?
Try NotebookLM Remover — Free