Untitled
unknown
plain_text
10 months ago
1.1 kB
33
Indexable
from PIL import Image, ImageDraw, ImageFont
# Load the image
image = Image.open("IMG_2130.jpeg").convert("RGB")
draw = ImageDraw.Draw(image)
# Define the text changes
replacements = [
{"text": "5/21/2025 4:40 PM", "replacement": "09/30/2025 3:18 PM"},
{"text": "5/22/2025", "replacement": "09/30/2025"},
{"text": "5:15 PM", "replacement": "3:18 PM"}
]
# You might need to manually locate the coordinates if OCR isn't perfect
# These are example coordinates and should be adapted to your image
coordinates = [
(240, 58), # For "5/21/2025 4:40 PM"
(400, 750), # For "5/22/2025"
(550, 750) # For "5:15 PM"
]
# Optional: Use a font available on your system
font = ImageFont.load_default()
# Draw white boxes to "erase" old text
for (x, y) in coordinates:
draw.rectangle([x, y, x+150, y+15], fill="white")
# Add the new text
for i, (x, y) in enumerate(coordinates):
draw.text((x, y), replacements[i]["replacement"], fill="black", font=font)
# Save the edited image
image.save("updated_summary.jpeg")
print("Image updated and saved as 'updated_summary.jpeg'")
Editor is loading...
Leave a Comment