Fix transparent AI avatar cutout and woven Mento logo mark.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-01 16:28:45 +03:30
co-authored by Cursor
parent 57fa6c8d12
commit 2b0c985d19
10 changed files with 172 additions and 71 deletions
+26
View File
@@ -0,0 +1,26 @@
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)
+35
View File
@@ -0,0 +1,35 @@
from PIL import Image
src = r"C:\Users\Mahdi\.cursor\projects\e-projeha-crm\assets\mento-ai-avatar-transparent.png"
dst = r"e:\projeha\crm\apps\web\public\brand\mento-ai-avatar.png"
img = Image.open(src).convert("RGBA")
pixels = img.load()
w, h = img.size
cx, cy = w / 2, h / 2
radius = min(w, h) * 0.42
for y in range(h):
for x in range(w):
r, g, b, a = pixels[x, y]
if r > 245 and g > 245 and b > 245:
pixels[x, y] = (r, g, b, 0)
continue
# leftover dark plate far from character
if r < 40 and g < 70 and b < 80 and a > 200:
dist = ((x - cx) ** 2 + (y - cy) ** 2) ** 0.5
if dist > radius:
pixels[x, y] = (r, g, b, 0)
bbox = img.getbbox()
if bbox:
img = img.crop(bbox)
pad = 12
padded = Image.new("RGBA", (img.width + pad * 2, img.height + pad * 2), (0, 0, 0, 0))
padded.paste(img, (pad, pad), img)
img = padded
img.save(dst, "PNG")
px = img.load()
print("saved", dst, img.size)
print("corner alpha", px[0, 0][3], px[img.width - 1, 0][3])
+40
View File
@@ -0,0 +1,40 @@
from PIL import Image
src = r"C:\Users\Mahdi\.cursor\projects\e-projeha-crm\assets\mento-logo-mark.png"
dst_png = r"e:\projeha\crm\apps\web\public\brand\mento-logo.png"
img = Image.open(src).convert("RGBA")
pixels = img.load()
w, h = img.size
for y in range(h):
for x in range(w):
r, g, b, a = pixels[x, y]
# white canvas
if r > 235 and g > 235 and b > 235:
pixels[x, y] = (255, 255, 255, 0)
continue
# black / near-black canvas
if r < 28 and g < 28 and b < 28:
pixels[x, y] = (0, 0, 0, 0)
continue
# dark fringe around logo on black plate
if r < 40 and g < 45 and b < 50 and (r + g + b) < 110:
pixels[x, y] = (0, 0, 0, 0)
bbox = img.getbbox()
if not bbox:
raise SystemExit("empty image after bg remove")
img = img.crop(bbox)
pad = 10
padded = Image.new("RGBA", (img.width + pad * 2, img.height + pad * 2), (0, 0, 0, 0))
padded.paste(img, (pad, pad), img)
img = padded
side = max(img.width, img.height)
canvas = Image.new("RGBA", (side, side), (0, 0, 0, 0))
canvas.paste(img, ((side - img.width) // 2, (side - img.height) // 2), img)
canvas.save(dst_png, "PNG")
px = canvas.load()
print("logo saved", dst_png, canvas.size, "corner", px[0, 0])