Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
#!/usr/bin/env python3
"""Regenerate every WebBrain logo derivative from the canonical brand assets.
The full-background artwork works well for social cards. Toolbar, favicon,
and store-icon sizes use the matching transparent brain mark so browser chrome
does not show it as a tiny boxed thumbnail. Requires Pillow.
"""
from __future__ import annotations
import shutil
from pathlib import Path
from PIL import Image, ImageDraw
ROOT = Path(__file__).resolve().parent.parent
CANONICAL = ROOT / "assets" / "logo-github.png"
MARK = ROOT / "assets" / "logo-mark.png"
ASSETS = ROOT / "assets"
WEB = ROOT / "web"
# Static branded graphics that embed the logo directly. Their surrounding
# layout stays untouched; only the existing logo tile is replaced.
COMPOSITE_LOGOS = (
(ASSETS / "banners" / "webbrain-banner-en.png", (140, 228, 396, 484), 48),
(ASSETS / "banners" / "webbrain-banner-tr.png", (140, 228, 396, 484), 48),
(ASSETS / "banners" / "webbrain-banner-vertical-en.png", (472, 456, 808, 792), 64),
(ASSETS / "webbrain-social-card-300x188.png", (91, 25, 126, 60), 8),
(ASSETS / "webbrain-social-card.png", (436, 84, 556, 204), 26),
(WEB / "assets" / "webbrain-ollama-heart.png", (202, 175, 460, 433), 30),
)
def full_logo(source: Image.Image, size: int) -> Image.Image:
return source.resize((size, size), Image.Resampling.LANCZOS)
def icon_logo(mark: Image.Image, size: int) -> Image.Image:
"""Crop the transparent mark around its alpha bounds with even padding."""
bounds = mark.getchannel("A").getbbox()
if not bounds:
raise SystemExit("Transparent logo mark has no visible pixels")
left, top, right, bottom = bounds
subject_side = max(right - left, bottom - top)
side = round(subject_side * 1.14)
center_x = (left + right) / 2
center_y = (top + bottom) / 2
crop_left = round(center_x - side / 2)
crop_top = round(center_y - side / 2)
cropped = mark.crop((crop_left, crop_top, crop_left + side, crop_top + side))
return cropped.resize((size, size), Image.Resampling.LANCZOS)
def save_png(image: Image.Image, path: Path) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
image.save(path, format="PNG", optimize=True)
def save_jpeg(image: Image.Image, path: Path) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
image.convert("RGB").save(
path,
format="JPEG",
quality=94,
optimize=True,
progressive=True,
)
def replace_composite_logo(path: Path, source: Image.Image, box: tuple[int, int, int, int], radius: int) -> None:
image = Image.open(path).convert("RGB")
left, top, right, bottom = box
width, height = right - left, bottom - top
if width != height:
raise SystemExit(f"Composite logo box must be square: {path} {box}")
tile = full_logo(source, width).convert("RGB")
mask = Image.new("L", (width, height), 0)
ImageDraw.Draw(mask).rounded_rectangle((0, 0, width - 1, height - 1), radius=radius, fill=255)
image.paste(tile, (left, top), mask)
save_png(image, path)
def main() -> None:
source = Image.open(CANONICAL).convert("RGB")
if source.size != (1254, 1254):
raise SystemExit(f"Unexpected canonical logo size: {source.size}; expected 1254×1254")
mark = Image.open(MARK).convert("RGBA")
if mark.size != source.size:
raise SystemExit(f"Unexpected transparent logo mark size: {mark.size}; expected {source.size}")
save_jpeg(full_logo(source, 128), ASSETS / "logo-github-128.jpg")
save_png(full_logo(source, 512), ASSETS / "logo-github-512.png")
save_jpeg(full_logo(source, 512), ASSETS / "logo-github-512.jpg")
for size in (64, 128):
save_png(icon_logo(mark, size), ASSETS / f"store-icon-{size}.png")
for browser in ("chrome", "firefox"):
icon_dir = ROOT / "src" / browser / "icons"
for size in (16, 48, 128):
save_png(icon_logo(mark, size), icon_dir / f"icon{size}.png")
shutil.copyfile(CANONICAL, WEB / "logo-github.png")
save_png(icon_logo(mark, 64), WEB / "favicon.png")
# Website social cards are typography-led composites generated by
# assets/brand-assets-2026-2/render.mjs. Do not replace them with
# logo-only derivatives here.
for path, box, radius in COMPOSITE_LOGOS:
replace_composite_logo(path, source, box, radius)
print("Synchronized WebBrain logo assets from assets/logo-github.png")
if __name__ == "__main__":
main()