mirror of
https://github.com/paradoxxxzero/butterfly.git
synced 2025-01-12 12:28:13 +00:00
32 lines
773 B
Python
Executable file
32 lines
773 B
Python
Executable file
#!/usr/bin/env python
|
|
#Depends: pillow
|
|
#Broken: Too slow !
|
|
from PIL import Image
|
|
import os
|
|
import mimetypes
|
|
import base64
|
|
import io
|
|
print('\x1bP;HTML|')
|
|
|
|
out = ''
|
|
|
|
for f in os.listdir(os.getcwd()):
|
|
mime = mimetypes.guess_type(f)[0]
|
|
if 'image' in (mime or ''):
|
|
# try:
|
|
with open(f, 'rb') as buf:
|
|
# im = Image.open(f)
|
|
# im.thumbnail((100, 100), Image.ANTIALIAS)
|
|
# buf = io.BytesIO()
|
|
# im.save(buf, im.format)
|
|
# buf.seek(0)
|
|
out += '<img width="200" height="100" src="data:%s;base64,%s" alt="%s" />' % (
|
|
mime,
|
|
base64.b64encode(buf.read()).decode('ascii'),
|
|
f)
|
|
# except Exception:
|
|
# pass
|
|
|
|
print(out)
|
|
|
|
print('\x1bP')
|