Trying to set up repo
This commit is contained in:
32
imagegen.py
Normal file
32
imagegen.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import datetime
|
||||
import pytz
|
||||
import asyncio
|
||||
import google_weather
|
||||
#from getweather import getweather
|
||||
# create an image
|
||||
out = Image.new("L", (800, 480),255)
|
||||
|
||||
# get a font
|
||||
fnt = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",25)
|
||||
fntBold = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf",35)
|
||||
# get a drawing context
|
||||
d = ImageDraw.Draw(out)
|
||||
|
||||
# create text
|
||||
txt1 = datetime.datetime.now(pytz.timezone('America/New_York')).strftime('%A %B %d, %Y %I:%M %p')
|
||||
# draw multiline text
|
||||
d.multiline_text((1, 1), txt1, font=fntBold, fill=0)
|
||||
#txt2 = "This is the day that the LORD has made\nWe will rejoice and be glad in it."
|
||||
#txt2 = asyncio.run(getweather())
|
||||
d.multiline_text((1, 35), "Weather:", font=fnt, fill=0)
|
||||
weather = google_weather.get_google_weather()
|
||||
txt2 = " Current: "+weather["current"] \
|
||||
+"\n Today's forecast: "+weather["forecast_today"] \
|
||||
+"\n Tomorrow: "+weather["forecast_tomorrow"]
|
||||
d.multiline_text((1, 60), txt2, font=fnt, fill=0)
|
||||
d.multiline_text((1, 135), "-----", font=fnt, fill=0)
|
||||
|
||||
out.save("/mnt/nfs/HomeAutomation/ForHA.jpg","JPEG")
|
||||
#out.show()
|
||||
|
||||
Reference in New Issue
Block a user