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

28 lines
981 B
Python

from PIL import Image
def inspect_text_pixels(path):
img = Image.open(path)
pixels = img.convert("RGBA").load()
width, height = img.size
non_bg_coords = []
for x in range(150, width):
for y in range(height):
r, g, b, a = pixels[x, y]
is_bg = (r >= 250 and g >= 250 and b >= 250)
if not is_bg:
non_bg_coords.append((x, y))
if non_bg_coords:
xs = [p[0] for p in non_bg_coords]
ys = [p[1] for p in non_bg_coords]
print(f"Non-background bounding box on right:")
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("All pixels in the right region are background.")
if __name__ == "__main__":
inspect_text_pixels("/Users/apple/.gemini/antigravity-ide/brain/822556bd-47a7-4c07-8975-803618af0a3a/media__1781946188768.png")