-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddingDate&Time.py
35 lines (25 loc) · 951 Bytes
/
AddingDate&Time.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
import json
from PIL import Image, ImageFont, ImageDraw
from datetime import date
API_key = "1b1946d3bc7177abc8fc1266caf9b5d9"
city = "Chicago"
URL = "http://api.openweathermap.org/data/2.5/weather?q={}&appid=1b1946d3bc7177abc8fc1266caf9b5d9&units=metric".format(city)
response = requests.get(URL)
Data = json.loads(response.text)
print(Data)
image = Image.open("Weather_post .png")# .png file that we added left side
draw = ImageDraw.Draw(image)
font = ImageFont.truetype('Inter-Medium.ttf', size=50) # intert
content = "Recent weather forecast"
color = 'rgb(255, 255, 255)'
(x,y) = (55,50)
draw.text((x,y), content, color, font=font)
font = ImageFont.truetype('Inter-Medium.ttf', size=30) # intert
today = date.today()
content = date.today().strftime("%A- %B %d, %Y" ) #
color = 'rgb(255, 255, 255)'
(x,y) = (45,145)
draw.text((x,y), content, color, font=font)
image.show()# showing image
image.save("Weather_forecast.png")