mirror of
https://github.com/paradoxxxzero/butterfly.git
synced 2025-01-27 02:08:53 +00:00
31 lines
683 B
Python
Executable file
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')
|