Greyscale

This commit is contained in:
Evan Reichard 2022-11-17 09:13:35 -05:00
parent f286b23f6a
commit 77a4727cc0

View File

@ -6,7 +6,7 @@ from pathlib import Path
from threading import Thread from threading import Thread
import yaml import yaml
from PIL import Image from PIL import Image, ImageOps
class ScreenshotManager: class ScreenshotManager:
@ -29,10 +29,14 @@ class ScreenshotManager:
self.__loop_thread = Thread(target=self.__loop) self.__loop_thread = Thread(target=self.__loop)
self.__loop_thread.start() self.__loop_thread.start()
def __rotate_file(self, filename): def __process_image(self, ss):
filename = ss.get("output")
fp = Path(self.data_path, filename) fp = Path(self.data_path, filename)
img = Image.open(fp) img = ImageOps.grayscale(Image.open(fp))
if ss.get("rotate", False) is True:
img = img.rotate(90, expand=True) img = img.rotate(90, expand=True)
img.save(fp) img.save(fp)
def __loop(self): def __loop(self):
@ -43,8 +47,7 @@ class ScreenshotManager:
["shot-scraper", "multi", self.__config_path], cwd=self.data_path ["shot-scraper", "multi", self.__config_path], cwd=self.data_path
) )
for ss in self.__config_yaml: for ss in self.__config_yaml:
if ss.get("rotate", False) is True: self.__process_image(ss)
self.__rotate_file(ss.get("output"))
time.sleep(1) time.sleep(1)
counter += 1 counter += 1