From 60d8cbe3f228b144f3f03efc876fcf4de073b874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20=C5=A0mejkal?= Date: Fri, 2 Jun 2023 21:02:06 +0200 Subject: [PATCH] added my python utils I used this to make this project happen --- utils/downgrade.py | 18 ++++++++++++++++++ utils/rename.py | 15 +++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 utils/downgrade.py create mode 100644 utils/rename.py diff --git a/utils/downgrade.py b/utils/downgrade.py new file mode 100644 index 0000000..3403336 --- /dev/null +++ b/utils/downgrade.py @@ -0,0 +1,18 @@ +import os +from PIL import Image + +def main(): + for file in os.listdir(os.fsencode(".")): + filename = os.fsdecode(file) + + if not filename.endswith(".jpg"): continue + + foo = Image.open(filename) + + if foo.size[0] <= 3000 and foo.size[1] <= 3000: continue + + foo = foo.resize((1500, int((1500 / foo.size[0]) * foo.size[1])), Image.LANCZOS) + foo.save("downscaled/" + filename, quality=95) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/utils/rename.py b/utils/rename.py new file mode 100644 index 0000000..fd329b0 --- /dev/null +++ b/utils/rename.py @@ -0,0 +1,15 @@ +import os + +def main(): + number = 1 + + for file in os.listdir(os.fsencode(".")): + filename = os.fsdecode(file) + + if not filename.endswith(".py"): + os.rename(filename, str(number) + "." + filename.split(".")[1]) + number += 1 + #print(number) + +if __name__ == "__main__": + main() \ No newline at end of file