From c11731345467a9542b9dd4e9557ffd36b06542f0 Mon Sep 17 00:00:00 2001 From: jonathan Date: Thu, 23 Nov 2023 19:17:34 +1030 Subject: [PATCH] add argparse and comment to imagecleaner --- imagecleaner.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/imagecleaner.py b/imagecleaner.py index 4fb01c6..68e3330 100644 --- a/imagecleaner.py +++ b/imagecleaner.py @@ -1,5 +1,6 @@ import sys, os, re -from PIL import Image as im +from PIL import Image as im +from argparse import ArgumentParser as argparser # width in pixels MAX_WIDTH = 720 @@ -38,6 +39,11 @@ def handle_directory(dirpath): return def verify_file_is_image(filepath): + # note that this isnt a bulletproof way to check a file is _actually_ an + # image, but pil can figure out the filetype for us if its been misattributed + # in the file metadata - this just stops us from wasting time trying to + # process markdown files or js code, but also means we're not relying on some + # stupid fucking package solution for an extremely simple problem return os.path.splitext(filepath)[1] in IMG_FM def process_image(filepath):