From 77a4727cc015260be1aa10a267b85c22f6ef18bd Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Thu, 17 Nov 2022 09:13:35 -0500 Subject: [PATCH] Greyscale --- kiss/ssmanager.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/kiss/ssmanager.py b/kiss/ssmanager.py index 45de294..2341ba2 100644 --- a/kiss/ssmanager.py +++ b/kiss/ssmanager.py @@ -6,7 +6,7 @@ from pathlib import Path from threading import Thread import yaml -from PIL import Image +from PIL import Image, ImageOps class ScreenshotManager: @@ -29,10 +29,14 @@ class ScreenshotManager: self.__loop_thread = Thread(target=self.__loop) self.__loop_thread.start() - def __rotate_file(self, filename): + def __process_image(self, ss): + filename = ss.get("output") fp = Path(self.data_path, filename) - img = Image.open(fp) - img = img.rotate(90, expand=True) + img = ImageOps.grayscale(Image.open(fp)) + + if ss.get("rotate", False) is True: + img = img.rotate(90, expand=True) + img.save(fp) def __loop(self): @@ -43,8 +47,7 @@ class ScreenshotManager: ["shot-scraper", "multi", self.__config_path], cwd=self.data_path ) for ss in self.__config_yaml: - if ss.get("rotate", False) is True: - self.__rotate_file(ss.get("output")) + self.__process_image(ss) time.sleep(1) counter += 1