I was proud of myself until...

Posted on
Fri Aug 26, 2022 7:26 am
Different Computers offline
User avatar
Posts: 2579
Joined: Jan 02, 2016
Location: East Coast

I was proud of myself until...

So using directions at https://www.geeksforgeeks.org/python-pi ... watermark/ I modified this script to get it to put text on an image:

Code: Select all
from PIL import Image
import time
from PIL import ImageFont
from PIL import ImageDraw
import matplotlib.pyplot as plt
import numpy as np

original = Image.open("/Library/Application Support/Perceptive Automation/Indigo 2022.1/Web Assets/public/alert.jpg")

draw = ImageDraw.Draw(original)
font = ImageFont.truetype("Arial", 37)
draw.text((55, 23), "timestamp", (255, 255, 0), font=font)
plt.subplot(1, 2, 1)
plt.title("white text")

original.save("/Library/Application Support/Perceptive Automation/Indigo 2022.1/Web Assets/public/alert.jpg", optimize=True, quality=38)
And that works fine.

But when I follow these timestamp directions https://stackoverflow.com/questions/687 ... rrent-time and do

Code: Select all
from PIL import Image
import time
from PIL import ImageFont
from PIL import ImageDraw
import matplotlib.pyplot as plt
import numpy as np

original = Image.open("/Library/Application Support/Perceptive Automation/Indigo 2022.1/Web Assets/public/alert.jpg")

draw = ImageDraw.Draw(original)
font = ImageFont.truetype("Arial", 37)
draw.text((55, 23), draw.text((55, 23), datetime.datetime.now().strftime("%d-%H-%M-%S"), (255, 255, 0), font=font)
plt.subplot(1, 2, 1)
plt.title("white text")

original.save("/Library/Application Support/Perceptive Automation/Indigo 2022.1/Web Assets/public/alert.jpg", optimize=True, quality=38)


I get "name datetime is not defined". Some sort of syntax error on my part I'm sure, but I can't figure it out. What did I do wrong? So close!

I'm also confused about what the line "
Code: Select all
plt.title("white text")
does, since the text color comes from two lines above that. Thanks in advance!

Sonoma on a Mac Mini M1 running Airfoil Pro, Bond Home, Camect, Roku Network Remote, Hue Lights, DomoPad, Adapters, Home Assistant Agent, HomeKitLinkSiri, EPS Smart Dimmer, Fantastic Weather, Nanoleaf, LED Simple Effects, Grafana. UnifiAP

Posted on
Fri Aug 26, 2022 7:40 am
Different Computers offline
User avatar
Posts: 2579
Joined: Jan 02, 2016
Location: East Coast

Re: I was proud of myself until...

Ha! I got it!

Thanks anyway. The timestamp example didn't show
Code: Select all
import datetime


I m SMRT :D

Sonoma on a Mac Mini M1 running Airfoil Pro, Bond Home, Camect, Roku Network Remote, Hue Lights, DomoPad, Adapters, Home Assistant Agent, HomeKitLinkSiri, EPS Smart Dimmer, Fantastic Weather, Nanoleaf, LED Simple Effects, Grafana. UnifiAP

Posted on
Fri Aug 26, 2022 3:19 pm
DaveL17 offline
User avatar
Posts: 6787
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: I was proud of myself until...

Good job.

We were all figuring it out at some point.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Aug 27, 2022 8:18 am
ryanbuckner offline
Posts: 1081
Joined: Oct 08, 2011
Location: Northern Virginia

Re: I was proud of myself until...

DaveL17 wrote:
Good job.

We were all figuring it out at some point.


Agreed. Great job.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests