

Tell HN: Turn small images to html for fun - ff0066mote

<i>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)</i><p>from sys import argv
from base64 import b64encode
from os.path import split, splitext<p>ifn = argv[1]
alt, ext = splitext(ifn)
ext = ext.lstrip('.')
ofn = alt+'.html'
alt = split(alt)[1]<p>ifd = open(ifn, 'rb')
ofd = open(ofn, 'wb')<p>ofd.write( '&#60;img src="data:image/{0};base64,{1}" alt="{2}" /&#62;'.format(ext, b64encode(ifd.read()), alt))<p>ifd.close()
ofd.close()
======
aufreak3
Gimp lets you export images into HTML tables :) It even asks you whether
you're sane and really want to do it!

~~~
ff0066mote
Photoshop does that too. This method is different because it uses the data URI
scheme to encode the (small) image as base64 data in the <img /> tag. No
tables here!

