added my python utils

I used this to make this project happen
This commit is contained in:
Václav Šmejkal 2023-06-02 21:02:06 +02:00 committed by GitHub
parent 21e37fcf21
commit 60d8cbe3f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

18
utils/downgrade.py Normal file
View File

@ -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()

15
utils/rename.py Normal file
View File

@ -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()