diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py
index 334f26f..eba9312 100644
--- a/distribusi/distribusi.py
+++ b/distribusi/distribusi.py
@@ -7,27 +7,18 @@ import magic
from PIL import Image
from distribusi.page_template import html_footer, html_head
-
-CODE_TYPES = ['x-c', 'html']
-
-FILE_TYPES = {
- 'image': '',
- 'pdf': (
- ''
- ),
- 'text': '{}',
- 'video': (''),
- 'audio': (''),
-}
-
+from distribusi.mappings import CODE_TYPES, FILE_TYPES
MIME_TYPE = magic.Magic(mime=True)
def caption(image):
- process = subprocess.Popen(['exiftool', '-Comment', image], stdout=subprocess.PIPE)
- out, err = process.communicate()
+ try:
+ process = subprocess.Popen(['exiftool', '-Comment', image], stdout=subprocess.PIPE)
+ out, err = process.communicate()
+ except Exception as e:
+ print(e)
+ print('Do you have exiftool installed?')
try:
caption = out.decode("utf-8").split(": ", 1)[1]
except:
@@ -36,21 +27,25 @@ def caption(image):
def thumbnail(image, name, args):
- size = (450, 450)
- im = Image.open(image)
- im.thumbnail(size)
- output = BytesIO()
- im.save(output, format='JPEG')
- im_data = output.getvalue()
- data_url = base64.b64encode(im_data).decode()
- cap = caption(image)
- if cap and args.captions:
- cap = "