added thumbconf.json support -> customize thumb size

This commit is contained in:
Dooho Yi 2021-11-23 14:37:45 +00:00
parent a87cc2d489
commit 22adda7adc
2 changed files with 14 additions and 4 deletions

View file

@ -18,6 +18,7 @@ import uuid
from distribusi.ignore import Ignore
import traceback
import json
MIME_TYPE = magic.Magic(mime=True)
@ -41,9 +42,10 @@ def caption(image):
return caption
def thumbnail(image, name, args):
def thumbnail(image, name, args, size=(450,450)):
try:
size = (450, 450)
# size = (450, 450)
im = Image.open(image)
exif = None
try:
@ -201,7 +203,14 @@ def render_dir(args, directory):
if type_ == 'image':
a = FILE_TYPES[type_].format(relative_path, c, c)
if args.thumbnail:
a = thumbnail(full_path, relative_path, args)
thumbconf_path = "./{}/{}".format(root, "thumbconf.json")
size = (450, 450)
if os.path.isfile(thumbconf_path):
with open(thumbconf_path) as json_file:
json_data = json.load(json_file)
size = tuple(json_data['size'])
print("applying thumbconf.json: size: ", size)
a = thumbnail(full_path, relative_path, args, size)
if args.no_filenames:
c = ""
if args.captions:

View file

@ -13,3 +13,4 @@ style.css
main.js
.+.alt
events
thumbconf.json