# build_banner.py
from PIL import Image, ImageDraw, ImageFont
# ---------------------------------------------------------------------------
# CONFIG
# ---------------------------------------------------------------------------
W, H = 2048, 1152 # Canvas size
SAFE_W, SAFE_H = 1546, 423 # YouTube safe area
BG_COLOR = (0x1a, 0x1a, 0x1a) # #1a1a1a
UNION_OPACITY = 28 # 11% of 255 ≈ 28
STRIPE_COLOR = (0x00, 0x55, 0xff) # #0055ff
STRIPE_H = 10 # px
HANDLE_TEXT = "@AUDITTHEAUDITORS"
TAGLINE_1 = "In defence of all police officers in the United Kingdom"
TAGLINE_2 = "Doing the right things, in the right way, for the right reasons."
WHITE = (255, 255, 255)
ICON_OPACITY = 217 # ~85% of 255
OUTPUT_FILE = "audit_the_auditors_banner.png"
DPI = (300, 300)
# ---------------------------------------------------------------------------
# LOAD FONTS
# ---------------------------------------------------------------------------
font_bold = ImageFont.truetype("Montserrat-Bold.ttf", 110)
font_regular = ImageFont.truetype("Montserrat-Regular.ttf", 42)
# ---------------------------------------------------------------------------
# CREATE BASE LAYER
# ---------------------------------------------------------------------------
banner = Image.new("RGB", (W, H), BG_COLOR)
draw = ImageDraw.Draw(banner)
# ---------------------------------------------------------------------------
# ADD LOW-OPACITY UNION JACK
# ---------------------------------------------------------------------------
uj = Image.new("RGBA", (W, H), (0, 0, 0, 0))
uj_draw = ImageDraw.Draw(uj)
# Draw diagonals
uj_draw.line([(0, 0), (W, H)], fill=(0, 0, 0, UNION_OPACITY), width=int(H*0.09))
uj_draw.line([(0, H), (W, 0)], fill=(0, 0, 0, UNION_OPACITY), width=int(H*0.09))
# Draw vertical & horizontal crosses
uj_draw.rectangle([(W/2 - H*0.045, 0), (W/2 + H*0.045, H)],
fill=(0, 0, 0, UNION_OPACITY))
uj_draw.rectangle([(0, H/2 - H*0.045), (W, H/2 + H*0.045)],
fill=(0, 0, 0, UNION_OPACITY))
banner = Image.alpha_composite(banner.convert("RGBA"), uj).convert("RGB")
# ---------------------------------------------------------------------------
# DRAW BLUE STRIPE
# ---------------------------------------------------------------------------
stripe_y = H//2 - STRIPE_H//2
draw.rectangle([(0, stripe_y), (W, stripe_y + STRIPE_H)], fill=STRIPE_COLOR)
# ---------------------------------------------------------------------------
# CALCULATE TEXT POSITIONS (CENTERED WITHIN SAFE ZONE)
# ---------------------------------------------------------------------------
safe_x0 = (W - SAFE_W)//2
safe_y0 = (H - SAFE_H)//2
# Main handle
handle_w, handle_h = draw.textsize(HANDLE_TEXT, font=font_bold)
handle_x = (W - handle_w)//2
handle_y = stripe_y - handle_h - 18 # 18 px gap above blue line
# Taglines
tag1_w, tag1_h = draw.textsize(TAGLINE_1, font=font_regular)
tag2_w, tag2_h = draw.textsize(TAGLINE_2, font=font_regular)
tag1_x = (W - tag1_w)//2
tag1_y = stripe_y + STRIPE_H + 18 # 18 px gap below blue line
tag2_x = (W - tag2_w)//2
tag2_y = tag1_y + tag1_h + 6 # 6 px inter-line leading
# ---------------------------------------------------------------------------
# RENDER TEXT
# ---------------------------------------------------------------------------
draw.text((handle_x, handle_y), HANDLE_TEXT, font=font_bold, fill=WHITE)
draw.text((tag1_x, tag1_y), TAGLINE_1, font=font_regular, fill=WHITE)
draw.text((tag2_x, tag2_y), TAGLINE_2, font=font_regular, fill=WHITE)
# ---------------------------------------------------------------------------
# ICONS: SIMPLE SILHOUETTES USING BASIC SHAPES (NO EXTERNAL FILES)
# ---------------------------------------------------------------------------
icons = Image.new("RGBA", (W, H), (0, 0, 0, 0))
ic_draw = ImageDraw.Draw(icons)
# Custodian helmet (left)
helmet_w = 160
helmet_h = 200
helmet_x = safe_x0 + 40
helmet_y = stripe_y - helmet_h//2
ic_draw.ellipse([(helmet_x, helmet_y + 20),
(helmet_x + helmet_w, helmet_y + 20 + helmet_h)],
fill=(0, 0, 0, ICON_OPACITY))
ic_draw.rectangle([(helmet_x + helmet_w*0.15, helmet_y),
(helmet_x + helmet_w*0.85, helmet_y + helmet_h*0.35)],
fill=(0, 0, 0, ICON_OPACITY))
# Little badge circle
ic_draw.ellipse([(helmet_x + helmet_w*0.4, helmet_y + helmet_h*0.35),
(helmet_x + helmet_w*0.6, helmet_y + helmet_h*0.55)],
fill=(BG_COLOR[0], BG_COLOR[1], BG_COLOR[2], 255))
# Patrol car (right) – minimalist blocky silhouette
car_w = 200
car_h = 90
car_x = W - safe_x0 - car_w - 40
car_y = stripe_y + STRIPE_H + 100
ic_draw.rectangle([(car_x, car_y), (car_x + car_w, car_y + car_h)],
fill=(0, 0, 0, ICON_OPACITY))
ic_draw.polygon([(car_x + car_w*0.25, car_y),
(car_x + car_w*0.45, car_y - 45),
(car_x + car_w*0.7 , car_y - 45),
(car_x + car_w*0.85, car_y)],
fill=(0, 0, 0, ICON_OPACITY))
# Wheels
ic_draw.ellipse([(car_x + car_w*0.18 - 20, car_y + car_h - 15),
(car_x + car_w*0.18 + 20, car_y + car_h + 25)],
fill=(0, 0, 0, ICON_OPACITY))
ic_draw.ellipse([(car_x + car_w*0.78 - 20, car_y + car_h - 15),
(car_x + car_w*0.78 + 20, car_y + car_h + 25)],
fill=(0, 0, 0, ICON_OPACITY))
# Composite icons
banner = Image.alpha_composite(banner.convert("RGBA"), icons).convert("RGB")
# ---------------------------------------------------------------------------
# SAVE @ 300 DPI
# ---------------------------------------------------------------------------
banner.save(OUTPUT_FILE, dpi=DPI)
print(f"Banner saved as {OUTPUT_FILE}")