Emulating mode=map with python mapscript
Ryan, Adam
ARyan at CO.LINN.OR.US
Wed Dec 8 11:35:04 PST 2004
Dear list,
I'd like to emulate mode=map using python mapscript, but I'm getting errors.
Is this how it's done:?:?
#--------------------------
import mapscript
mapO = mapscript.mapObj("mymap.map")
mapImg = mapO.draw()
print "Content-Type: image/png\n"
print mapImg.write()
#--------------------------
IE gives me that little empty image icon (no surprise there) while Mozilla
tells me "The image cannot be displayed because it contains errors" and
running it on the command line gives me my header and a bunch of gobbly
guck:
Content-Type: image/png
ëPNG
→
IHDR d d♦♥ ☺⌡╦╕± §PLTE 2═2 d ⌂▒⌂ÿµÿ♥Å¡┬ ☻5IDATx£φXKr├
♀ea∙\YP»YD
¼╜ ε⌂ä"■_█IgÜÖ╓o2!X~↕↕Æáel
...
I know the map file is fine because the regular method works without a
hitch:
#--------------------------
import mapscript
mapO = mapscript.mapObj("mymap.map")
mapImg = mapO.draw()
mapImg.save("myimg.png")
print "Content-Type: text/html\n"
print "<html><body>"
print "<img src='myimg.png'>"
print "</body></html>"
#--------------------------
Any thoughts? Cheers to all,
Adam
More information about the MapServer-users
mailing list