Files
crm/scripts/cleanup_avatar_plate.py

27 lines
865 B
Python

from PIL import Image
# Force-clear any remaining opaque black plate around AI avatar too
path = r"e:\projeha\crm\apps\web\public\brand\mento-ai-avatar.png"
img = Image.open(path).convert("RGBA")
px = img.load()
w, h = img.size
cleared = 0
for y in range(h):
for x in range(w):
r, g, b, a = px[x, y]
if a == 0:
continue
# leftover flat dark teal/black plate
if r < 45 and g < 70 and b < 85 and max(r, g, b) - min(r, g, b) < 35:
# keep cyan glow pixels (more green/blue variance + brighter cyan)
if b > 120 or g > 140:
continue
px[x, y] = (r, g, b, 0)
cleared += 1
elif r > 248 and g > 248 and b > 248:
px[x, y] = (255, 255, 255, 0)
cleared += 1
img.save(path, "PNG")
print("cleared", cleared, "pixels; size", img.size)