new photos directories

This commit is contained in:
Martin Quarda 2024-10-07 05:58:19 +02:00
parent cdf660287d
commit f99a079b71

View File

@ -192,17 +192,18 @@ def results(request):
def photos(request): def photos(request):
files = glob.glob("photos/*.jpg") for (i, name) in ALKATOR_CLASSES:
rtn = [] files = glob.glob(f"photos/{i}/*.jpg")
random.shuffle(files) rtn = []
for file in files: random.shuffle(files)
img = PIL.Image.open(file) for file in files:
rtn.append({ img = PIL.Image.open(file)
'original': '/' + file.replace(".jpg", ".webp"), rtn.append({
'thumbnail': '/' + file.replace('photos/', 'photos/thumbnail/').replace(".jpg", ".webp"), 'original': '/' + file.replace(".jpg", ".webp"),
'original_width': img.width, 'thumbnail': '/' + file.replace('photos/', 'photos/thumbnail/').replace(".jpg", ".webp"),
'original_height': img.height, 'original_width': img.width,
}) 'original_height': img.height,
})
return HttpResponse(json.dumps(rtn), content_type='application/json') return HttpResponse(json.dumps(rtn), content_type='application/json')