1 |
#!/usr/bin/python |
#!/usr/bin/python |
2 |
|
|
3 |
import cgi, Image, ImageDraw, sys, math |
import cgi, Image, ImageDraw, sys, math, signal, errno, os |
4 |
from string import atoi, atof |
from string import atoi, atof |
5 |
|
|
6 |
|
def handler(signum, frame): |
7 |
|
raise os.error, (errno.ETIME, "Timer expired") |
8 |
|
|
9 |
|
signal.alarm(55) |
10 |
|
signal.signal(signal.SIGALRM, handler) |
11 |
|
|
12 |
# This is to get backtrace output |
# This is to get backtrace output |
13 |
sys.stderr = sys.stdout |
sys.stderr = sys.stdout |
14 |
|
|
80 |
iy= atof(form['image.y'].value) |
iy= atof(form['image.y'].value) |
81 |
owidth= atof(form['owidth'].value) |
owidth= atof(form['owidth'].value) |
82 |
oheight= atof(form['oheight'].value) |
oheight= atof(form['oheight'].value) |
83 |
diagp= math.sqrt(width**2 + height**2) |
diagp= math.sqrt(owidth**2 + oheight**2) |
84 |
scale= diagp/diag |
scale= diagp/diag |
85 |
cx= (ix/scale) + (cx - (width / (scale*2))) |
cx= (ix/scale) + (cx - (owidth / (scale*2))) |
86 |
cy= ((height-iy)/scale) + (cy - (height / (scale*2))) |
cy= ((oheight-iy)/scale) + (cy - (oheight / (scale*2))) |
87 |
if form.has_key('zoom'): |
if form.has_key('zoom'): |
88 |
zoom=atof(form['zoom'].value) |
zoom=atof(form['zoom'].value) |
89 |
diag=diag/zoom |
diag=diag/zoom |
123 |
print '<INPUT TYPE=HIDDEN NAME="%s" VALUE="%s">' % var |
print '<INPUT TYPE=HIDDEN NAME="%s" VALUE="%s">' % var |
124 |
print '<INPUT TYPE=HIDDEN NAME=type VALUE="html">' |
print '<INPUT TYPE=HIDDEN NAME=type VALUE="html">' |
125 |
|
|
126 |
print """</FORM> |
print """</FORM><P> |
127 |
|
After changing any settings, don't forget to change the "Zoom" setting |
128 |
|
to "Pan" if you don't want to zoom when applying them. |
129 |
</BODY></HTML>""" |
</BODY></HTML>""" |
130 |
sys.exit(0) |
sys.exit(0) |
131 |
|
|
255 |
else: |
else: |
256 |
yto= yorig # End at x axis |
yto= yorig # End at x axis |
257 |
|
|
258 |
drawrect((0, yfrom), (xmax, yto)) |
try: |
259 |
|
drawrect((0, yfrom), (xmax, yto)) |
260 |
|
except os.error, the_error: |
261 |
|
if the_error[0] != errno.ETIME: |
262 |
|
raise os.error, the_error |
263 |
|
|
264 |
|
signal.alarm(0) |
265 |
|
|
266 |
print "Content-type: image/png" |
print "Content-type: image/png" |
267 |
print |
print |