38 lines
858 B
Python
38 lines
858 B
Python
from papiezator.models import Pope
|
|
from PIL import Image
|
|
from os import path
|
|
PREFIX = "popes"
|
|
|
|
class PopeMaster:
|
|
def __init__(self):
|
|
pass
|
|
|
|
|
|
def parse_popes(self):
|
|
self.parse_pope("papiez.jpg")
|
|
|
|
def parse_pope(self, pope):
|
|
im = Image.open(pope)
|
|
width, height = im.size
|
|
Pope(pope, width, height)
|
|
aspect_ratio = round(width/height, 2)
|
|
print(pope, width, height,aspect_ratio)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import os
|
|
|
|
os.environ ['PYTHONPATH'] = '/home/daz/Documents/Projects/Py/django/papiez_ipsum'
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'papiez_ipsum.settings'
|
|
|
|
os.chdir("../")
|
|
print(os.getcwd())
|
|
|
|
|
|
pm = PopeMaster()
|
|
|
|
with open('popes/pope_list') as file:
|
|
for line in file:
|
|
pope = line.rstrip()
|
|
pm.parse_pope(path.join(PREFIX, pope))
|