Files
sci-gui-agent-benchmark/utils/image_processing/mark_point.py

33 lines
875 B
Python

from PIL import Image, ImageDraw
def mark_point(image_path: str, x: int, y: int, radius: int = 5, color: str = 'red') -> str:
"""
Mark a point on an image and save the image.
"""
# Load the image
image = Image.open(image_path)
# Create a draw object
draw = ImageDraw.Draw(image)
# Draw a small circle to mark the point
draw.ellipse((x - radius, y - radius, x + radius, y + radius), fill=color, outline=color)
# Save the image with the point marked
marked_image_path = image_path[:-4] + '_marked' + image_path[-4:]
image.save(marked_image_path)
return marked_image_path
if __name__ == '__main__':
image_path = 'chrome_start.png'
x = 100
y = 200
radius = 30
color = 'red'
marked_image_path = mark_point(image_path, x, y, radius, color)
print(f"Marked image saved to {marked_image_path}")