Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created October 31, 2011 13:48
Show Gist options
  • Save ralphbean/1327533 to your computer and use it in GitHub Desktop.
Save ralphbean/1327533 to your computer and use it in GitHub Desktop.
ansi2html test
#!/usr/bin/env python
"""
The great test for ansi2html. Can it reliably reproduce images that have been
converted to ansi color by fabulous?
Before running this, install the following in a virtualenv::
$ pip install ansi2html fabulous PIL
Author: Ralph Bean -- http://threebean.org
"""
import ansi2html
import fabulous.image
import tempfile
import urllib
if __name__ == '__main__':
fname = tempfile.mkstemp(prefix='lime')[1]
urllib.urlretrieve("http://threebean.org/lime.jpg", fname)
img = fabulous.image.Image(fname, width=160)
html = ansi2html.Ansi2HTMLConverter().convert(str(img))
print html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment