-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
29 lines (24 loc) · 908 Bytes
/
app.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
import pyscreeze
import time
from db_functions import img_to_db
from settings import PIC_EXT, PREV_PIC
def take_screenshot(the_date,the_time):
global PREV_PIC
initial_pic = "screenshot/current1"+PIC_EXT
img = pyscreeze.screenshot(initial_pic)
print("Screenshot taken")
# Resize the fullscreen screenshot
y_ratio = img.size[1]/img.size[0]
dimension_x = float(img.size[0])*.82
dimension_y = dimension_x*y_ratio
img.thumbnail((dimension_x, dimension_y))
img.save(initial_pic, quality=90)
with open(initial_pic, "rb") as file:
# If the length of bytes is the same as previous picture,
# picture will not be saved bc guess is it's the same pic, saves db space.
crnt = len(file.read())
if PREV_PIC == crnt:
print("Same Screenshot")
return
PREV_PIC = crnt
img_to_db(the_time, the_date, initial_pic)