[中文文档](README_zh.md) # Gemini & NotebookLM Watermark Cleaner A privacy-first, browser-based tool for removing watermarks from Gemini and NotebookLM generated content (Images & PDFs). Built with vanilla JavaScript, featuring mathematical precision for lossless restoration and robust fallback cloning for complex document formats.

## ✨ Features - **Multi-Format Support**: Handles standard Gemini Images (`.jpg`, `.png`, `.webp`) and NotebookLM documents (`.pdf`). - **Lossless Restoration**: Uses **Reverse Alpha Blending** for standard Gemini images to perfectly restore original pixels without blurring. - **Smart Cloning**: Applies intelligent **Simple Clone** (patching) for NotebookLM headers/footers and PDF slides where alpha maps don't apply. - **Privacy-First**: 100% client-side processing. No files are ever uploaded to any server. - **Batch Processing**: Process multiple files at once and download them as a ZIP archive. - **Modern UI**: Dark/Light mode support with a clean, responsive interface. - **PDF Preview**: Real-time progress tracking and preview for PDF file cleaning. ## 🛠️ Technology Stack - **Core Logic**: Vanilla JavaScript (ES Modules) - **PDF Processing**: `pdfjs-dist` (Parsing) & `jspdf` (Re-generation) - **UI Styling**: Tailwind CSS (CDN) - **Packaging**: `esbuild` for bundling ## 🧩 How It Works This tool employs two distinct strategies depending on the content type: ### 1. Reverse Alpha Blending (for Gemini Images) Gemini applies watermarks using a standard alpha compositing formula: $$Pixel_{watermarked} = \alpha \cdot Pixel_{logo} + (1 - \alpha) \cdot Pixel_{original}$$ We reverse this to recover the original pixel: $$Pixel_{original} = \frac{Pixel_{watermarked} - \alpha \cdot Pixel_{logo}}{1 - \alpha}$$ By using pre-calibrated Alpha Maps (48px/96px), we can mathematically restore the original pixel values with near-zero loss. ### 2. Smart Cloning (for NotebookLM & PDF) For NotebookLM's strip-like watermarks or PDF slides where exact alpha maps vary, the tool uses a **Simple Clone** technique. It identifies the watermark region and intelligently "clones" a patch of pixels from the immediate neighborhood (e.g., just above the watermark) to cover it, blending the edges for a seamless look. ## 🔗 Attribution & References This project is built upon the excellent work of the open-source community. Special thanks to: - **Original Project**: [gemini-watermark-remover](https://github.com/journey-ad/gemini-watermark-remover) by [journey-ad](https://github.com/journey-ad). - *Base architecture, alpha map logic, and core "Reverse Alpha Blending" implementation.* - **Algorithm Origin**: [Gemini Watermark Tool](https://github.com/allenk/GeminiWatermarkTool) by [Allen Kuo](https://github.com/allenk). - *Original discovery of the math and watermark masks.* ## 🚀 Usage ### Development 1. Clone the repository: ```bash git clone http://git.unissense.tech/mula/gemini_watermark_cleaner.git ``` 2. Install dependencies: ```bash pnpm install ``` 3. Start development mode (rebuilds on changes): ```bash pnpm dev ``` 4. Start a local preview server: ```bash pnpm serve ``` 5. Build for production: ```bash pnpm build ``` ### Docker Deployment 1. Build and run the container: ```bash docker-compose up -d --build ``` 2. The application will be available at `http://localhost:3000` (or the port specified in `.env`). ### Browser Simply open the `dist/index.html` (after building) or the deployed site. Drag and drop your files. - **Images**: Instant preview and cleaning. - **PDFs**: Shows progress per page, then displays the cleaned first page. ## 📄 License [MIT License](./LICENSE)