b379f4adda
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
148 lines
10 KiB
Python
148 lines
10 KiB
Python
# LinkSpin promo kit: crops of the three kie.ai key visuals + typeset copy (Rajdhani display / Manrope body, the site's
|
|
# own fonts). Output -> linkspin/site/public/kit/ls-<slot>.(jpg|png). Neutral file names on purpose (no IAB size tokens:
|
|
# EasyList blocks those URLs). No earnings figures anywhere, no POL figures.
|
|
from PIL import Image, ImageDraw, ImageFont, ImageFilter
|
|
import os, pathlib
|
|
HERE = pathlib.Path(__file__).parent; OUT = pathlib.Path('D:/Projects/HighRisk/linkspin/site/public/kit'); OUT.mkdir(exist_ok=True)
|
|
LAND = Image.open(HERE / 'masters/master-landscape.png').convert('RGB')
|
|
PORT = Image.open(HERE / 'masters/master-portrait.png').convert('RGB')
|
|
SQ = Image.open(HERE / 'masters/master-square.png').convert('RGB')
|
|
def FD(px): return ImageFont.truetype(str(HERE / 'fonts/Rajdhani-Bold.ttf'), px)
|
|
def FB(px, w='SemiBold'):
|
|
f = ImageFont.truetype(str(HERE / 'fonts/Manrope.ttf'), px); f.set_variation_by_name(w); return f
|
|
BLUE = (59, 157, 255); ORANGE = (255, 106, 26); FG = (236, 242, 250); MUTED = (176, 192, 216); INK = (6, 18, 37)
|
|
LAND_FOCUS = (0.36, 0.5); PORT_FOCUS = (0.5, 0.42); SQ_FOCUS = (0.5, 0.52)
|
|
|
|
def crop_to(im, w, h, focus):
|
|
W, H = im.size; r = w / h
|
|
if W / H > r: cw, ch = int(H * r), H
|
|
else: cw, ch = W, int(W / r)
|
|
cx, cy = int(focus[0] * W), int(focus[1] * H)
|
|
x = min(max(cx - cw // 2, 0), W - cw); y = min(max(cy - ch // 2, 0), H - ch)
|
|
return im.crop((x, y, x + cw, y + ch)).resize((w, h), Image.LANCZOS)
|
|
def shade(im, box, strength=0.78, blur=18):
|
|
x0, y0, x1, y1 = [int(v) for v in box]; ov = Image.new('L', im.size, 0); d = ImageDraw.Draw(ov)
|
|
d.rounded_rectangle((x0, y0, x1, y1), radius=min(40, (y1 - y0) // 3), fill=int(255 * strength))
|
|
if blur: ov = ov.filter(ImageFilter.GaussianBlur(blur))
|
|
dark = Image.new('RGB', im.size, (7, 12, 24)); im.paste(dark, (0, 0), ov); return im
|
|
def tw(d, s, f): return d.textlength(s, font=f)
|
|
def tracked(d, xy, s, f, fill, track=0):
|
|
x, y = xy
|
|
for ch in s: d.text((x, y), ch, font=f, fill=fill); x += d.textlength(ch, font=f) + track
|
|
return x
|
|
def tracked_w(d, s, f, track): return sum(d.textlength(c, font=f) for c in s) + track * (len(s) - 1)
|
|
def wordmark(d, x, y, px):
|
|
f = FB(px, 'Bold'); d.text((x, y), 'Link', font=f, fill=FG); x2 = x + tw(d, 'Link', f); d.text((x2, y), 'Spin', font=f, fill=BLUE); return x2 + tw(d, 'Spin', f)
|
|
def wordmark_w(d, px): f = FB(px, 'Bold'); return tw(d, 'LinkSpin', f)
|
|
def button(d, x, y, label, f, padx=18, pady=9, radius=6, fill=ORANGE, ink=(255, 255, 255)):
|
|
w = tw(d, label, f) + padx * 2; h = f.size + pady * 2
|
|
d.rounded_rectangle((x, y, x + w, y + h), radius=radius, fill=fill)
|
|
d.text((x + padx, y + pady - f.size * 0.08), label, font=f, fill=ink); return w, h
|
|
def ring_dot(d, x, y, r): # tiny mark: blue ring with an orange point, the LinkSpin glyph
|
|
d.ellipse((x - r, y - r, x + r, y + r), outline=BLUE, width=max(2, r // 4)); d.ellipse((x + r * 0.55, y - r * 0.9, x + r * 0.55 + r * 0.5, y - r * 0.9 + r * 0.5), fill=ORANGE)
|
|
|
|
HEAD_A = ['ONE LINK.', 'EVERY PAGE', 'YOU PROMOTE.']; SUB_A = 'Spin links, bridge pages and an ad slot for your site. Free.'
|
|
HEAD_B = ['PAID THE', 'MOMENT THEY', 'BUY.']; SUB_B = 'Half of every ad package in your line, same transaction, on Polygon.'
|
|
CTA = 'Join free'
|
|
|
|
def social(name, head, sub, w=1200, h=630, src=LAND, focus=LAND_FOCUS):
|
|
im = crop_to(src, w, h, focus); d = ImageDraw.Draw(im)
|
|
shade(im, (0, 0, w * 0.52, h), 0.7, 40); d = ImageDraw.Draw(im)
|
|
x = int(w * 0.055); y = int(h * 0.11); wordmark(d, x, y, int(h * 0.075))
|
|
fh = FD(int(h * 0.165)); y = int(h * 0.26)
|
|
for i, line in enumerate(head): tracked(d, (x, y), line, fh, ORANGE if i == len(head) - 1 else FG, 1); y += int(fh.size * 0.92)
|
|
fs = FB(int(h * 0.046)); y += int(h * 0.03)
|
|
# wrap sub to ~46% width
|
|
words = sub.split(); lines = []; cur = ''
|
|
for wd in words:
|
|
t = (cur + ' ' + wd).strip()
|
|
if tw(d, t, fs) > w * 0.44 and cur: lines.append(cur); cur = wd
|
|
else: cur = t
|
|
if cur: lines.append(cur)
|
|
for line in lines: d.text((x, y), line, font=fs, fill=MUTED); y += int(fs.size * 1.45)
|
|
y += int(h * 0.03); button(d, x, y, CTA, FD(int(h * 0.062)), padx=int(h * 0.04), pady=int(h * 0.02), radius=8)
|
|
im.save(OUT / (name + '.jpg'), 'JPEG', quality=86, optimize=True, progressive=True)
|
|
|
|
def square(name, w=1080, h=1080):
|
|
im = crop_to(SQ, w, h, SQ_FOCUS); d = ImageDraw.Draw(im)
|
|
shade(im, (0, 0, w, h * 0.5), 0.6, 60); d = ImageDraw.Draw(im)
|
|
x = int(w * 0.07); y = int(h * 0.07); wordmark(d, x, y, int(h * 0.05))
|
|
fh = FD(int(h * 0.1)); y = int(h * 0.15)
|
|
for i, line in enumerate(HEAD_A): tracked(d, (x, y), line, fh, ORANGE if i == 2 else FG, 2); y += int(fh.size * 0.92)
|
|
fs = FB(int(h * 0.031)); y += int(h * 0.015); d.text((x, y), 'Spin links, bridge pages, an ad slot for your site.', font=fs, fill=MUTED); y += int(fs.size * 1.5)
|
|
d.text((x, y), 'Payouts the moment your people buy. Free to join.', font=fs, fill=MUTED)
|
|
bw, bh = button(d, x, int(h * 0.86), CTA, FD(int(h * 0.045)), padx=int(h * 0.035), pady=int(h * 0.016), radius=10)
|
|
im.save(OUT / (name + '.jpg'), 'JPEG', quality=86, optimize=True, progressive=True)
|
|
|
|
def story(name, w=1080, h=1920):
|
|
im = crop_to(PORT, w, h, PORT_FOCUS); d = ImageDraw.Draw(im)
|
|
shade(im, (0, 0, w, h * 0.36), 0.62, 70); shade(im, (0, h * 0.78, w, h), 0.7, 60); d = ImageDraw.Draw(im)
|
|
x = int(w * 0.08); y = int(h * 0.07); wordmark(d, x, y, int(w * 0.055))
|
|
fh = FD(int(w * 0.125)); y = int(h * 0.13)
|
|
for i, line in enumerate(HEAD_A): tracked(d, (x, y), line, fh, ORANGE if i == 2 else FG, 2); y += int(fh.size * 0.92)
|
|
fs = FB(int(w * 0.034)); y = int(h * 0.80); d.text((x, y), 'Spin links, bridge pages, an ad slot for your site.', font=fs, fill=MUTED); y += int(fs.size * 1.5)
|
|
d.text((x, y), 'Payouts the moment your people buy.', font=fs, fill=MUTED); y += int(fs.size * 1.9)
|
|
button(d, x, y, CTA, FD(int(w * 0.05)), padx=int(w * 0.04), pady=int(w * 0.018), radius=10)
|
|
im.save(OUT / (name + '.jpg'), 'JPEG', quality=86, optimize=True, progressive=True)
|
|
|
|
def wide(name, w, h): # 728x90, 468x60, 320x50
|
|
im = crop_to(LAND, w, h, (0.36, 0.5)); d = ImageDraw.Draw(im)
|
|
shade(im, (0, 0, w, h), 0.55, 10); d = ImageDraw.Draw(im)
|
|
pad = int(h * 0.18); wm = int(h * 0.3); x = pad; wordmark(d, x, (h - wm * 1.25) // 2, wm); x += wordmark_w(d, wm) + int(h * 0.3)
|
|
fb = FD(int(h * 0.27)); bl = CTA if w >= 468 else 'Join'; bw = tw(d, bl, fb) + int(h * 0.5)
|
|
if w >= 468:
|
|
fh = FD(int(h * 0.36)); line = 'ONE LINK. EVERY PAGE YOU PROMOTE.' if w >= 728 else 'ONE LINK, EVERY PAGE.'
|
|
avail = w - x - bw - pad * 2
|
|
while tracked_w(d, line, fh, 1) > avail and fh.size > 10: fh = FD(fh.size - 1)
|
|
tracked(d, (x, (h - fh.size * 1.05) // 2), line, fh, FG, 1)
|
|
button(d, w - bw - pad, (h - (fb.size + int(h * 0.16))) // 2, bl, fb, padx=int(h * 0.25), pady=int(h * 0.08), radius=5)
|
|
im.save(OUT / (name + '.png'), 'PNG', optimize=True)
|
|
|
|
def rect(name, w, h): # 336x280, 300x250, 250x250
|
|
im = crop_to(SQ, w, h, (0.5, 0.68)); d = ImageDraw.Draw(im)
|
|
shade(im, (0, 0, w, h * 0.66), 0.7, 24); d = ImageDraw.Draw(im)
|
|
pad = int(w * 0.06); wm = int(w * 0.06); wordmark(d, pad, pad, wm)
|
|
fh = FD(int(w * 0.125)); y = pad + int(wm * 1.9)
|
|
for i, line in enumerate(HEAD_A): tracked(d, (pad, y), line, fh, ORANGE if i == 2 else FG, 1); y += int(fh.size * 0.9)
|
|
fb = FD(int(w * 0.062)); button(d, pad, h - pad - fb.size - int(w * 0.05), CTA, fb, padx=int(w * 0.045), pady=int(w * 0.022), radius=6)
|
|
im.save(OUT / (name + '.png'), 'PNG', optimize=True)
|
|
|
|
def tall(name, w, h): # 160x600, 120x600
|
|
im = crop_to(PORT, w, h, (0.5, 0.45)); d = ImageDraw.Draw(im)
|
|
shade(im, (0, 0, w, h * 0.42), 0.66, 20); shade(im, (0, h * 0.84, w, h), 0.7, 14); d = ImageDraw.Draw(im)
|
|
pad = int(w * 0.09); wm = int(w * 0.13); wordmark(d, pad, pad, wm)
|
|
fh = FD(int(w * 0.2)); y = pad + int(wm * 2.1)
|
|
for i, line in enumerate(['ONE', 'LINK.', 'EVERY', 'PAGE', 'YOU', 'PROMOTE.']): tracked(d, (pad, y), line, fh, ORANGE if i >= 4 else FG, 1); y += int(fh.size * 0.9)
|
|
fb = FD(int(w * 0.13)); bw = tw(d, 'Join free', fb) + int(w * 0.2)
|
|
button(d, (w - bw) // 2, h - pad - fb.size - int(w * 0.14), 'Join free', fb, padx=int(w * 0.1), pady=int(w * 0.06), radius=5)
|
|
im.save(OUT / (name + '.png'), 'PNG', optimize=True)
|
|
|
|
def tile(name, w=125, h=125):
|
|
im = crop_to(SQ, w, h, (0.5, 0.5)); d = ImageDraw.Draw(im); shade(im, (0, 0, w, h), 0.5, 10); d = ImageDraw.Draw(im)
|
|
f = FB(int(w * 0.17), 'Bold'); ww = tw(d, 'LinkSpin', f); x = (w - ww) // 2; y = int(h * 0.3); wordmark(d, x, y, int(w * 0.17))
|
|
fb = FD(int(w * 0.14)); bw = tw(d, 'Join free', fb) + int(w * 0.18); button(d, (w - bw) // 2, int(h * 0.58), 'Join free', fb, padx=int(w * 0.09), pady=int(w * 0.05), radius=4)
|
|
im.save(OUT / (name + '.png'), 'PNG', optimize=True)
|
|
|
|
social('ls-social-a', HEAD_A, SUB_A)
|
|
social('ls-social-b', HEAD_B, SUB_B)
|
|
social('ls-group', HEAD_A, SUB_A, 1280, 720)
|
|
square('ls-square'); story('ls-story')
|
|
wide('ls-leader', 728, 90); wide('ls-strip', 468, 60); wide('ls-bar', 320, 50)
|
|
rect('ls-panel', 336, 280); rect('ls-box', 300, 250); rect('ls-square-s', 250, 250)
|
|
tall('ls-tower', 160, 600); tall('ls-column', 120, 600); tile('ls-tile')
|
|
# contact sheet
|
|
files = sorted(os.listdir(OUT)); print('\n'.join(f + ' ' + str(os.path.getsize(OUT / f) // 1024) + 'KB' for f in files))
|
|
ims = [Image.open(OUT / f).convert('RGB') for f in files]; cols = 3; cw = 520; rows = (len(ims) + cols - 1) // cols
|
|
cells = []
|
|
for im in ims:
|
|
s = min(cw / im.width, 420 / im.height, 1.0); cells.append(im.resize((max(1, int(im.width * s)), max(1, int(im.height * s))), Image.LANCZOS))
|
|
rh = [max(c.height for c in cells[i:i + cols]) for i in range(0, len(cells), cols)]
|
|
sheet = Image.new('RGB', (cols * (cw + 16) + 16, sum(rh) + 16 * (rows + 1) + 20 * rows), (24, 26, 32)); d = ImageDraw.Draw(sheet); y = 16
|
|
for r in range(rows):
|
|
for c in range(cols):
|
|
k = r * cols + c
|
|
if k >= len(cells): break
|
|
x = 16 + c * (cw + 16); sheet.paste(cells[k], (x, y + 20)); d.text((x, y + 2), files[k] + ' ' + str(ims[k].width) + 'x' + str(ims[k].height), fill=(220, 225, 235))
|
|
y += rh[r] + 16 + 20
|
|
sheet.save(HERE / 'kit-sheet.jpg', 'JPEG', quality=82); print('sheet ok')
|