Tell HN: Turn small images to html for fun
I just made this small thing for fun. Please enjoy! I place it in the public domain. Python code follows. (Sorry about the newlines not coming through)
from sys import argv from base64 import b64encode from os.path import split, splitext
ifn = argv[1] alt, ext = splitext(ifn) ext = ext.lstrip('.') ofn = alt+'.html' alt = split(alt)[1]
ifd = open(ifn, 'rb') ofd = open(ofn, 'wb')
ofd.write( '<img src="data:image/{0};base64,{1}" alt="{2}" />'.format(ext, b64encode(ifd.read()), alt))
ifd.close() ofd.close()
2 comments
[ 3.4 ms ] story [ 14.2 ms ] thread