From 5e8e21b113864cc269bc3d79acb6cfecad5193ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dzikie=20dro=C5=BCd=C5=BCe?= Date: Mon, 6 Jan 2014 02:16:07 +0100 Subject: [PATCH] smuteczek --- .../templates/papiezator/index.html | 4 ++ src/pope_sanitizer | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/pope_sanitizer diff --git a/src/papiezator/templates/papiezator/index.html b/src/papiezator/templates/papiezator/index.html index d2e697e..1f1d32f 100644 --- a/src/papiezator/templates/papiezator/index.html +++ b/src/papiezator/templates/papiezator/index.html @@ -36,6 +36,10 @@ Jan Paweł II wypełniał małe strony + +
+ beta feature: - ratzinger! +

How do i popes?

simply append width/height of the pope you need to the url.

diff --git a/src/pope_sanitizer b/src/pope_sanitizer new file mode 100644 index 0000000..3b3ee4c --- /dev/null +++ b/src/pope_sanitizer @@ -0,0 +1,43 @@ +#!/usr/bin/env python +import PIL.Image +from glob import glob +from os import path +import os + + +exts = [".jpg", ".jpeg", ".png", ".gif"] + + +def remove(pope): + if os.path.isdir(pope): + return + pope_dir = path.dirname(pope) + borked_path = path.join(pope_dir, "borked") + if not path.exists(borked_path): + os.mkdir(borked_path) + + file = os.path.split(pope)[1] + move_to = os.path.join(borked_path, file) + os.rename(pope, move_to) + + + + + + +for pope in ["JP2", "B16"]: + print("dealing with {}".format(pope)) + pope_images = glob("popes/{pope}/*".format(pope=pope)) + for image in (x for x in pope_images if not path.isdir(x)): + try: + i = PIL.Image.open(image) + x, y = i.size + except: + print("{image} seems to be borked".format(image=image)) + input() + if x < 300 or y < 300: + print("{image} seems to be small".format(image=image)) + remove(image) + ext = path.splitext(image)[1] + if ext not in exts : + print("{image} seems to have a fucked up extension".format(image=image))