From 9e3e7c3e9437876ccbbf6f9bb41c8251b1b4af21 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 2 Oct 2026 15:20:35 -0500 Subject: [PATCH] Logo from a domain, programmatic generate() - logo_fetch.py: find a company's logo from its domain (homepage logo candidates, staging URLs, touch icons, favicon services), cached by domain - generate_sprite.py: --domain / --logo-cache, domain column in --batch, logos as PIL images, generate(..., write_files=False) for use as a library --- README.md | 46 ++- generate_sprite.py | 58 ++-- logo_fetch.py | 678 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 765 insertions(+), 17 deletions(-) create mode 100755 logo_fetch.py diff --git a/README.md b/README.md index 079a5cd..8fcb0b2 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,9 @@ python generate_sprite.py "Rosas Landscaping" logos/rosas.png --type grass --rer # Both libraries side by side python generate_sprite.py "Rosas Landscaping" logos/rosas.png --type grass --compare + +# No logo file: find the logo on the business's website +python generate_sprite.py "Rosas Landscaping" --domain rosaslandscaping.com --type grass ``` Each run writes `sprites/.png`, `sprites/@4x.png` and `sprites/.json` (library, type, parts, colors). With `--reroll N`, the file names end in `-rN`. With `--compare`, each library writes `-.*` and `-compare.png` shows them next to each other at the same height. Both use the same type and colors. @@ -51,12 +54,14 @@ Each run writes `sprites/.png`, `sprites/@4x.png` and `sprites/ python generate_sprite.py --batch businesses.csv --out sprites @@ -64,6 +69,45 @@ OPENROUTER_API_KEY= python generate_sprite.py --batch businesses.csv -- Add `--compare` to get both libraries for every row. +## Logo from a domain + +`logo_fetch.py` finds a business's logo from its website and caches it by domain. + +```bash +python logo_fetch.py rosaslandscaping.com --out logos # -> logos/rosaslandscaping.com.png (method) +python logo_fetch.py rosaslandscaping.com --extra https://staging.example.net/ # also search this page +``` + +```python +from logo_fetch import fetch_logo, fetch_logo_info, normalize_domain +fetch_logo("rosaslandscaping.com", "logos") # Path or None +fetch_logo_info("rosaslandscaping.com", "logos", extra_urls=["https://staging.example.net/"]) # (Path or None, method) +normalize_domain("HTTPS://www.Rosas.com/about") # "rosas.com" +``` + +Search order, best first. The first image with a brand hue wins; an image with only white/black/gray is kept as a fallback in case nothing colorful turns up (its method ends in `-mono`). + +| Method | Source | +|---|---| +| `site-logo` | The homepage (https, then http, without and with www): images with "logo" in class/id/file name/alt, images in a logo/brand container, the first image in `
`/`