Files
nearle_web_nextjs/scratch/find_icon_bounds.py
2026-06-20 15:41:55 +05:30

28 lines
906 B
Python

from PIL import Image
def find_icon_bounds(path):
img = Image.open(path)
pixels = img.convert("RGBA").load()
width, height = img.size
xs = []
ys = []
for x in range(150): # Look at left side only
for y in range(height):
r, g, b, a = pixels[x, y]
# Detect purple pixels (not white background)
if r < 150 and g < 100 and b > 100:
xs.append(x)
ys.append(y)
if xs:
print(f"Icon bounding box:")
print(f"X: {min(xs)} to {max(xs)} (width={max(xs) - min(xs) + 1})")
print(f"Y: {min(ys)} to {max(ys)} (height={max(ys) - min(ys) + 1})")
else:
print("No purple pixels found in left region.")
if __name__ == "__main__":
find_icon_bounds("/Users/apple/.gemini/antigravity-ide/brain/822556bd-47a7-4c07-8975-803618af0a3a/media__1781946188768.png")