[Mapserver-users] Sending image to stdout under Apache

Lowell Filak lfilak at medinaco.org
Wed Mar 5 14:14:22 EST 2003


>From what I can tell from the mod_perl comments is that using OUT as opposed to STDOUT is the way to fix it in mod_perl.
Lowell F.

The following message was sent by Jason Thaxter <jason at gomoos.org> on Wed, 5 Mar 2003 12:44:23 -0500.

> I checked our script when NOT run under mod_perl, and it works fine.  That's a
> better workaround for us than print/cat, since we have one script that does
> all the UI work, and a short one that generates the image output.
> 
> The problem I've identified, precisely, is that with the API you can write to
> a filename or stdout.  But writing to the "real" stdout doesn't work under
> mod_perl, since perl STDOUT is no longer the same as C stdout.  You can't
> pass a file handle; the choice with the current API is a filename, or nothing
> for stdout...
> 
> What we really want is something like what can be done with the perl GD
> interface, e.g:
> 	print $img->png;
> or even
> 	$img->printImage(\*STDOUT,args..);
> 
> Passing a filehandle as opposed to a string containing a filename isn't the
> craziest thing... OTOH, there might be a quicker way to get this accomplished
> with some select() trickery...  Or we might have to resort to writing an
> actual module, instead of writing Apache::Registry stuff...  We'll post our
> solution if we get anything better than what we have.
> 
> JT
> 
> 
> On Wed, Mar 05, 2003 at 10:57:23AM +0000, Eric Bridger wrote:
> > Thanks Lowell,
> > 
> > Yes, that was the work-around I mentioned.  But avoiding the write to
> > disk is what I am after.  I have found that using /cgi-bin/mapserv as an
> > image engine results in significant performance improvements for our
> > mapscript application.  But constructing the proper query strings to
> > manipulate the map is cumbersome and seems to have certain limitations. 
> > I'd prefer to manipulate the map using mapscript and then print it to
> > the stdout. But somehow, using $img->saveImage(undef, ...) which spends
> > some time doing something, never sends the image to the stdout when run
> > as a CGI.  From the command line, it works.
> > 
> > We don't have this problem with a graphing application in the same
> > environment which uses GD.pm.
> > 
> > 
> > On Wed, 2003-03-05 at 15:27, Lowell Filak wrote:
> > > Hmmm...
> > > I thought I replied back concerning that.?
> > > Just do a:
> > > print "Content-type: image/png\n\n";
> > > system("cat junk.png");
> > > and that will send the image to stdout/the browser.
> > > HTH
> > > Lowell F.
> > > 
> 
> -- 
> ----------------------------------------------
> Jason Thaxter
> GoMOOS, P.O. Box 4919, Portland, ME 04112-4919
> Office Location: 1 Canal Plaza, 7th Floor
> Office: 207.773.0423
> Fax:    207.773.8672
> Email:  thaxter at gomoos.org
> ------------www.gomoos.org--------------------




More information about the mapserver-users mailing list