Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 27 lines (22 sloc) 874 Bytes
#!/bin/env python3
# Originally by James Gregson
import os, requests
import argparse
def formula_as_file(formula, file, negate=False):
tfile = file
if negate:
tfile = 'tmp_cog.png'
r = requests.get( '\dpi{300} \huge %s' % formula )
f = open( tfile, 'wb' )
f.write( r.content )
if negate:
os.system( 'convert tmp.png -channel RGB -negate -colorspace rgb %s' %file )
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("code", help="The LaTeX math code you would like converted to an image")
parser.add_argument("out", help="The output image (png)")
args = parser.parse_args()
formula_as_file(args.code, args.out)