added thumbconf.json support -> customize thumb size
This commit is contained in:
parent
a87cc2d489
commit
22adda7adc
2 changed files with 14 additions and 4 deletions
|
|
@ -18,6 +18,7 @@ import uuid
|
||||||
from distribusi.ignore import Ignore
|
from distribusi.ignore import Ignore
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
import json
|
||||||
|
|
||||||
MIME_TYPE = magic.Magic(mime=True)
|
MIME_TYPE = magic.Magic(mime=True)
|
||||||
|
|
||||||
|
|
@ -41,9 +42,10 @@ def caption(image):
|
||||||
return caption
|
return caption
|
||||||
|
|
||||||
|
|
||||||
def thumbnail(image, name, args):
|
def thumbnail(image, name, args, size=(450,450)):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
size = (450, 450)
|
# size = (450, 450)
|
||||||
im = Image.open(image)
|
im = Image.open(image)
|
||||||
exif = None
|
exif = None
|
||||||
try:
|
try:
|
||||||
|
|
@ -201,7 +203,14 @@ def render_dir(args, directory):
|
||||||
if type_ == 'image':
|
if type_ == 'image':
|
||||||
a = FILE_TYPES[type_].format(relative_path, c, c)
|
a = FILE_TYPES[type_].format(relative_path, c, c)
|
||||||
if args.thumbnail:
|
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:
|
if args.no_filenames:
|
||||||
c = ""
|
c = ""
|
||||||
if args.captions:
|
if args.captions:
|
||||||
|
|
|
||||||
|
|
@ -13,3 +13,4 @@ style.css
|
||||||
main.js
|
main.js
|
||||||
.+.alt
|
.+.alt
|
||||||
events
|
events
|
||||||
|
thumbconf.json
|
||||||
Loading…
Reference in a new issue