Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Possible improvements #82

Open
3 tasks
mithi opened this issue Nov 2, 2020 · 0 comments
Open
3 tasks

Possible improvements #82

mithi opened this issue Nov 2, 2020 · 0 comments

Comments

@mithi
Copy link
Owner

mithi commented Nov 2, 2020

Dockerize this project

References

Add a description column for each tower

There is currently no description for each tower. Add a one for each

Add small thumbnails for each tower

Current size of each tower image: 470 px x 470 px

  • Run smaller versions (maybe 128px by 128px ?) of each image
  • Store in google file storage
  • store thumbnail url in a column in the database
from os.path import isfile, join
from os import listdir, walk, path
from PIL import Image

kr_dir = "./raw"
all_image_file_path = []
all_image_names = []
for (dirpath, dirnames, filenames) in walk(kr_dir):

    if dirpath in ["./raw"]:
        continue

    for i, filename in enumerate(filenames):
        [title, extension] = filename.split(".")
        kingdom = dirpath.split("/")[2]

        if extension.lower() not in ["jpg", "jpeg", "png"]:
            continue
        new_filename = kingdom + "-" + title +  ".png"

        image_file_path = path.join(dirpath, filename)
        print("new name", new_filename)
        all_image_names.append(new_filename)
        print("image_file_path", image_file_path)
        all_image_file_path.append(image_file_path)

fill_color = '#ffffff'
for i, (image_path, image_name) in enumerate(zip(all_image_file_path, all_image_names)):
    new_path =  path.join("./flat", image_name)
    print(i, new_path)

    image = Image.open(image_path)

    if image.mode in ('RGBA', 'LA'):
        background = Image.new(image.mode[:-1], image.size, fill_color)
        background.paste(image, image.split()[-1])
        image = background
        image = image.resize((470, 470))
        image.save(new_path, quality=95)
    else:
        image = image.resize((470, 470))
        image.save(new_path, quality=95)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant