Añadir mu-plugins y scripts de feadulta
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Issue #90 — círculo 200px RGBA (esquinas transparentes) para 2 autores nuevos.
|
||||
Recorte cuadrado centrado en la cara + máscara circular supersampleada.
|
||||
"""
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
SRC = "/home/rafa/Feadulta"
|
||||
OUT = "/home/rafa/joomla-migration/wordpress/wp-content/uploads/avatares/autores"
|
||||
SIZE = 200
|
||||
SS = 4 # supersampling para borde suave
|
||||
|
||||
# foto, uid, (left, top, side) recorte cuadrado en coords del original
|
||||
JOBS = [
|
||||
("MP_Lopez.jpeg", 474, (120, 0, 880)),
|
||||
("A_delaCruz.jpeg", 993, (128, 0, 785)),
|
||||
]
|
||||
|
||||
mask = Image.new("L", (SIZE * SS, SIZE * SS), 0)
|
||||
ImageDraw.Draw(mask).ellipse((0, 0, SIZE * SS - 1, SIZE * SS - 1), fill=255)
|
||||
mask = mask.resize((SIZE, SIZE), Image.LANCZOS)
|
||||
|
||||
for fname, uid, (l, t, side) in JOBS:
|
||||
im = Image.open(f"{SRC}/{fname}").convert("RGB")
|
||||
W, H = im.size
|
||||
# clamp dentro de la imagen
|
||||
l = max(0, min(l, W - side))
|
||||
t = max(0, min(t, H - side))
|
||||
crop = im.crop((l, t, l + side, t + side)).resize((SIZE, SIZE), Image.LANCZOS)
|
||||
out = Image.new("RGBA", (SIZE, SIZE), (0, 0, 0, 0))
|
||||
out.paste(crop, (0, 0))
|
||||
out.putalpha(mask)
|
||||
out.save(f"{OUT}/autor-{uid}.png")
|
||||
print(f"OK autor-{uid}.png <- {fname} crop=({l},{t},{side})")
|
||||
Reference in New Issue
Block a user