-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdesktop_background_script.py
More file actions
42 lines (32 loc) · 1.86 KB
/
desktop_background_script.py
File metadata and controls
42 lines (32 loc) · 1.86 KB
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
36
37
38
39
40
41
42
import requests
import json
import ctypes
import os
from PIL import Image, ImageOps
# Sources (via http://downlinkapp.com/sources.json):
source_dict = {"GOES-East": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/FD/GEOCOLOR/latest.jpg",
"GOES-West": "https://cdn.star.nesdis.noaa.gov/GOES17/ABI/FD/GEOCOLOR/latest.jpg",
"Himawari-8": "http://rammb.cira.colostate.edu/ramsdis/online/images/latest_hi_res/himawari-8/full_disk_ahi_true_color.jpg",
"Continental US": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/CONUS/GEOCOLOR/latest.jpg",
"Tropical Atlantic": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/taw/GEOCOLOR/latest.jpg",
"Tropical Pacific": "https://cdn.star.nesdis.noaa.gov/GOES17/ABI/SECTOR/tpw/GEOCOLOR/latest.jpg",
"US West Coast": "https://cdn.star.nesdis.noaa.gov/GOES17/ABI/CONUS/GEOCOLOR/latest.jpg",
"Northern Pacific": "https://cdn.star.nesdis.noaa.gov/GOES17/ABI/SECTOR/np/GEOCOLOR/latest.jpg",
"Northern South America": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/nsa/GEOCOLOR/latest.jpg",
"Southern South America": "https://cdn.star.nesdis.noaa.gov/GOES16/ABI/SECTOR/ssa/GEOCOLOR/latest.jpg"}
url = source_dict["Himawari-8"]
# Download image
image_data = requests.get(url).content
abspath = os.path.expanduser('~\\Pictures\\himawari.jpg')
with open(abspath, 'wb') as handler:
handler.write(image_data)
#reopen image
img = Image.open(abspath)
# make copy and edit
new_img = img.rotate(220)
new_img = new_img.crop((0, 0, 5500, 4000))
new_path = os.path.dirname(abspath) + r"\\himawari_mod.jpg"
ImageOps.expand(new_img, border=1000,fill='black').save(new_path)
SPIF_UPDATEINIFILE = 1
# update wallpaper
ctypes.windll.user32.SystemParametersInfoW(20, 0, new_path, SPIF_UPDATEINIFILE)