urlencoding added
This commit is contained in:
parent
0ece0ac28c
commit
eb1d85ad6b
1 changed files with 7 additions and 6 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
|
@ -64,12 +65,12 @@ def thumbnail(image, name, args):
|
||||||
im = im.rotate(270, expand=True)
|
im = im.rotate(270, expand=True)
|
||||||
elif exif[orientation] == 8:
|
elif exif[orientation] == 8:
|
||||||
im = im.rotate(90, expand=True)
|
im = im.rotate(90, expand=True)
|
||||||
|
|
||||||
if (im.mode == 'RGBA'):
|
if (im.mode == 'RGBA'):
|
||||||
bg = Image.new('RGBA', im.size, (255,255,255))
|
bg = Image.new('RGBA', im.size, (255,255,255))
|
||||||
composite = Image.alpha_composite(bg, im)
|
composite = Image.alpha_composite(bg, im)
|
||||||
im=composite.convert('RGB')
|
im=composite.convert('RGB')
|
||||||
|
|
||||||
output = BytesIO()
|
output = BytesIO()
|
||||||
im.save(output, format='JPEG')
|
im.save(output, format='JPEG')
|
||||||
im_data = output.getvalue()
|
im_data = output.getvalue()
|
||||||
|
|
@ -87,7 +88,7 @@ def thumbnail(image, name, args):
|
||||||
|
|
||||||
return (
|
return (
|
||||||
"<figure><a href='{}'><img class='thumbnail' src='data:image/jpg;base64,{}'></a><figcaption>{}</figcaption></figure>"
|
"<figure><a href='{}'><img class='thumbnail' src='data:image/jpg;base64,{}'></a><figcaption>{}</figcaption></figure>"
|
||||||
).format(name, data_url, cap)
|
).format(quote(name), data_url, cap)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Thumbnailer:', e)
|
print('Thumbnailer:', e)
|
||||||
cap = name
|
cap = name
|
||||||
|
|
@ -96,7 +97,7 @@ def thumbnail(image, name, args):
|
||||||
folder_name = m.group('name')
|
folder_name = m.group('name')
|
||||||
file_name = m.group('file')
|
file_name = m.group('file')
|
||||||
cap = folder_name + "/" + file_name
|
cap = folder_name + "/" + file_name
|
||||||
return "<figure><a href='{}'><img src='{}'></a><figcaption>{}</figcaption></figure>".format(name, name, cap)
|
return "<figure><a href='{}'><img src='{}'></a><figcaption>{}</figcaption></figure>".format(quote(name), name, cap)
|
||||||
|
|
||||||
|
|
||||||
def div(args, type_, subtype, tag, name, fid):
|
def div(args, type_, subtype, tag, name, fid):
|
||||||
|
|
@ -312,7 +313,7 @@ def distribusify(args, directory, freg): # noqa
|
||||||
print('Found', name, 'as', mime)
|
print('Found', name, 'as', mime)
|
||||||
|
|
||||||
if type_ in FILE_TYPES:
|
if type_ in FILE_TYPES:
|
||||||
|
|
||||||
a = FILE_TYPES[type_].format(name, c, c)
|
a = FILE_TYPES[type_].format(name, c, c)
|
||||||
|
|
||||||
# expansion for different kind of text files
|
# expansion for different kind of text files
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue