From 1708857772e9285e7f442617170cb30ca531f0ba Mon Sep 17 00:00:00 2001 From: Victor Kuznetsov Date: Mon, 1 Jun 2026 10:42:04 -0700 Subject: [PATCH] fix(gemini): expand sparkle search area 256 -> 512px from corner The 256px limit caused misses when Gemini places the sparkle further from the corner than the standard 160px (margin 64 + logo 96). Observed variant at ~300px reported in issue #30. 512px covers all known Gemini margin variations with room to spare; matchTemplate on a 512x512 region is still fast on CPU. Co-Authored-By: Claude Opus 4.8 --- pyproject.toml | 2 +- src/remove_ai_watermarks/__init__.py | 2 +- src/remove_ai_watermarks/gemini_engine.py | 6 ++++-- uv.lock | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c8f500a..6e5cec7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "remove-ai-watermarks" -version = "0.8.5" +version = "0.8.6" description = "Remove visible and invisible AI watermarks from images (Gemini / Nano Banana, ChatGPT, Stable Diffusion)" readme = "README.md" requires-python = ">=3.10" diff --git a/src/remove_ai_watermarks/__init__.py b/src/remove_ai_watermarks/__init__.py index ccb5a7c..7edcf77 100644 --- a/src/remove_ai_watermarks/__init__.py +++ b/src/remove_ai_watermarks/__init__.py @@ -11,4 +11,4 @@ _os.environ.setdefault("TRANSFORMERS_VERBOSITY", "error") _warnings.filterwarnings("ignore", message=r".*ImageProcessorFast.*") -__version__ = "0.8.5" +__version__ = "0.8.6" diff --git a/src/remove_ai_watermarks/gemini_engine.py b/src/remove_ai_watermarks/gemini_engine.py index 5ef7048..2add8ef 100644 --- a/src/remove_ai_watermarks/gemini_engine.py +++ b/src/remove_ai_watermarks/gemini_engine.py @@ -190,8 +190,10 @@ class GeminiEngine: # Use large alpha template (96x96) as the high-quality source for downscaling source_alpha = self._alpha_large - # Dynamically search bottom-right corner (search up to 256x256 region) - search_size = int(min(min(w, h), 256)) + # Dynamically search bottom-right corner. 512 covers up to 512px from the + # corner -- enough for known Gemini margin variations (standard: 64+96=160px; + # observed variants up to ~300px). 256 was too tight and caused misses. + search_size = int(min(min(w, h), 512)) sx1 = max(0, w - search_size) sy1 = max(0, h - search_size) diff --git a/uv.lock b/uv.lock index 9ca1f49..2da2896 100644 --- a/uv.lock +++ b/uv.lock @@ -2865,7 +2865,7 @@ wheels = [ [[package]] name = "remove-ai-watermarks" -version = "0.8.5" +version = "0.8.6" source = { editable = "." } dependencies = [ { name = "click" },