Metadata-Version: 2.4
Name: infographics-builder
Version: 2.0.0
Summary: CLI library for automated infographic poster generation: background removal, parallel headless rendering, color-based auto-patching and HTML asset validation.
License-Expression: MIT
Project-URL: Homepage, https://github.com/yourusername/infographics-builder
Project-URL: Issues, https://github.com/yourusername/infographics-builder/issues
Keywords: infographics,poster,rendering,rembg,pillow,background-removal,headless-chrome
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Utilities
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Pillow>=10.0.0
Requires-Dist: rembg>=2.0.0
Provides-Extra: progress
Requires-Dist: tqdm>=4.60.0; extra == "progress"
Dynamic: license-file

# infographics-builder

> CLI Python library for automated generation of high-quality infographic posters.  
> Background removal • Parallel headless rendering • BFS color auto-patching • Asset validation

---

## Features

| Command | Description |
|---------|-------------|
| `bg` | Remove background via `rembg` and center object on transparent canvas |
| `render` | Render HTML template to print-quality JPG (2400×3600px) via headless Brave/Chrome |
| `batch` | Parallel batch rendering of entire folder with progress bar and build log |
| `patch` | Surgical rectangular texture patching via linear color interpolation |
| `autopatch` | BFS-based automatic color region detection and patching (removes flags, labels) |
| `validate` | Pre-render validation of all local image assets in HTML template |

---

## Installation

```bash
pip install infographics-builder

# Optional: progress bar support
pip install infographics-builder[progress]
```

**Requirements:**
- Python 3.10+
- Brave Browser or Google Chrome (for `render` / `batch` commands)

---

## Quick Start

### Remove background from image
```bash
infographics-builder bg input_photo.jpg output.png
infographics-builder bg input_photo.jpg output.png --size 1024 --padding 40
```

### Render a single poster
```bash
infographics-builder render card.html poster.jpg
infographics-builder render card.html poster.jpg --browser "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe"
```

### Batch render entire folder (with skip-existing and auto log)
```bash
infographics-builder batch ./html_pages/ ./renders/
infographics-builder batch ./html_pages/ ./renders/ --workers 4 --no-skip
```

### Auto-patch unwanted color regions (flags, watermarks)
```bash
# Remove red (255,0,0) with tolerance 40
infographics-builder autopatch model.png 255 0 0 --tolerance 40

# Remove blue flag without creating a backup
infographics-builder autopatch model.png 0 0 200 --tolerance 30 --no-backup
```

### Manual texture patch by coordinates
```bash
infographics-builder patch model.png 580 620 340 380
infographics-builder patch model.png 580 620 340 380 --no-backup
```

### Validate HTML template assets
```bash
infographics-builder validate card.html
```

---

## Python API

```python
from infographics_builder import ImageProcessor, PosterRenderer, Validator

# Remove background
ImageProcessor.remove_background("photo.jpg", "output.png")

# Render poster
renderer = PosterRenderer()  # auto-detects Brave/Chrome
renderer.render("card.html", "poster.jpg")

# Batch render with progress bar
renderer.render_batch(
    html_paths=["card1.html", "card2.html"],
    output_jpg_paths=["poster1.jpg", "poster2.jpg"],
    skip_existing=True,   # skip already rendered
    log_dir="./logs/"     # write build_YYYY-MM-DD.log
)

# Auto-patch by color (BFS)
ImageProcessor.auto_patch_by_color("model.png", target_color_rgb=(255, 0, 0), tolerance=30)

# Validate assets
ok = Validator.validate_html("card.html")
```

---

## Rendering Architecture

The `render` command uses a Chromium-based headless browser with these flags:

```
--window-size=1200,1800 --force-device-scale-factor=2
```

This produces a **2400×3600px** screenshot (device-pixel-ratio 2x), which is then converted to JPG at 95% quality via Pillow.

---

## Safety Features

- **Auto-backup (`.bak`)**: `patch` and `autopatch` create a `.bak` copy before modifying any file. Disable with `--no-backup`.
- **Skip existing**: `batch` skips already-rendered JPGs by default (`--no-skip` to override).
- **Build log**: Every `batch` run writes `build_YYYY-MM-DD.log` in the output directory.

---

## License

MIT
