from PIL import Image

def find_icon_bounds_v2(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]
            # Any pixel that is NOT the white background (RGB is not all high)
            if r < 240 or g < 240 or b < 240:
                xs.append(x)
                ys.append(y)
                
    if xs:
        print(f"Icon bounding box (V2):")
        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 non-white pixels found in left region.")

if __name__ == "__main__":
    find_icon_bounds_v2("/Users/apple/.gemini/antigravity-ide/brain/822556bd-47a7-4c07-8975-803618af0a3a/media__1781946188768.png")
