Skip to content

Instantly share code, notes, and snippets.

Last active August 15, 2021 05:40
What would you like to do?
Filesystem events monitoring with Python []
import os
from PIL import Image
from PIL.ImageOps import grayscale
from import RegexMatchingEventHandler
class ImagesEventHandler(RegexMatchingEventHandler):
THUMBNAIL_SIZE = (128, 128)
IMAGES_REGEX = [r".*[^_thumbnail]\.jpg$"]
def __init__(self):
def on_created(self, event):
def process(self, event):
filename, ext = os.path.splitext(event.src_path)
filename = f"{filename}_thumbnail.jpg"
image =
image = grayscale(image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment