#! /usr/bin/env python from config import latexcommand, pscommand, gscommand, netpbmdir dpi = 150 res = 0.5 background = "" transparent = "ff/ff/ff" grey=1 greylev=255*1 # # Image generation and decoding commands for GIF and PNG output. # cmdGIF = netpbmdir+'ppmtogif' cmdGIFdecode = 'giftopnm' cmdPNG = 'pnmtopng' cmdPNGdecode = 'pngtopnm' f="1.tex" # # Default image creation modes # imageCmd = cmdGIF imageCmdD = cmdGIFdecode imageExt = 'gif' # # Command line option processing # import sys a=sys.argv for i in range(len(a)): if a[i]=="-dpi": dpi=a[i+1] if a[i]=="-res": res=a[i+1] if a[i]=="-grey": greylev=int(round(255*float(a[i+1]),0)) transparent=str(greylev) + "/" + str(greylev) + "/" +str(greylev) if a[i]=="-png": imageExt = 'png' # # Main file processing loop # f=a[1]; kataloog=f[0:f.rfind("/")] from time import time nimi=kataloog+"/temp"+str(int(time())) import os #par="echo x | /usr/local/teTeX/bin/i686-pc-linux-gnu/latex " + f+ "\n" #par="echo x | "+latexcommand+" " + f+ "\n" par=latexcommand+" -output-directory "+kataloog+" "+f+"\n" #os.system("cd "+kataloog) os.system(par) #par="/usr/local/teTeX/bin/i686-pc-linux-gnu/dvips -f " + f[0:(len(f)-3)]+ "dvi >"+nimi+".ps \n" par=pscommand+" -f " + f[0:(len(f)-3)]+ "dvi >"+nimi+".ps \n" os.system(par) jagatis=int(float(dpi)/float(res)) cmd1="echo quit | "+gscommand+" -q -dNOPAUSE -r"+ str(jagatis)+"x"+ str(jagatis)+" -sDEVICE=pbmraw -sOutputFile=- "+nimi+".ps | "+netpbmdir+"pnmcrop -white | "+netpbmdir+"pnmdepth 255 | "+netpbmdir+"pnmscale "+str(res)+" | "+imageCmd+ " -interlace -transparent rgb:"+ str(transparent)+" >" + f[0:(len(f)-3)]+ imageExt os.system(cmd1) kustuta="rm "+f[0:(len(f)-3)]+"dvi "+ f[0:(len(f)-3)]+"aux "+f[0:(len(f)-3)]+"log "+ nimi+".ps " os.system(kustuta)