paradoxxxzero_butterfly/bin/ils
2014-02-06 18:00:51 +01:00

31 lines
683 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('\x1b]99;')
out = ''
for f in os.listdir(os.getcwd()):
mime = mimetypes.guess_type(f)[0]
if 'image' in (mime or ''):
try:
im = Image.open(f)
im.thumbnail((100, 100), Image.ANTIALIAS)
buf = io.BytesIO()
im.save(buf, im.format)
buf.seek(0)
out += '<img src="data:%s;base64,%s" alt="%s" />' % (
mime,
base64.b64encode(buf.read()).decode('ascii'),
f)
except:
pass
print(out)
print('\x07')