import re,sys,os
d=sys.argv[1]
p=os.path.join(d,'pivotal_St.html'); s=open(p).read()
def dims(f):
t=open(os.path.join(d,f)).read(2000)
w=re.search(r'width=.([\d.]+)pt',t); h=re.search(r'height=.([\d.]+)pt',t)
return float(w.group(1)), float(h.group(1))
def rep(m):
f=m.group(1); w,h=dims(f)
return ""%(f,0.58*w,0.58*h)
s,n=re.subn(r"""\s*
]*?src=['"]([^'"]+)['"][^>]*?/>\s*""",rep,s)
s=s.replace("DEFORMATIONS OF DELIGNE’S St","DEFORMATIONS OF DELIGNE’S St").replace("