From: Rasputin Date: 2003-07-18T19:28:42+09:00 Subject: Re: Question re: graphics output of CGIs (mime-type issue?) * Hal E. Fulton [0728 01:28]: > What's the proper way to deliver a grpahical > file via HTTP? > > For example, supposing a web page has a bit of > HTML like: > > > > Then how should myprog.cgi deliver its output? > Is there direct support for this in one of the > libraries, or do you just have to know how to > do it? > > I tried just using a Content-type of image/jpeg, > but I got garbage in the browser. Don't some browsers insist on looking at filetype rather than mime-type? Two workarounds spring to mind (I've installed Ruby-GD for this very reason, but haven't tried yet): Would this work? #(Apache,mod_ruby) Options +ExecCGI SetHandler ruby-object RubyHandler Apache::RubyRun.instance Or alternatively (and haven't figured out how to do this yet) map all requests to a particular location to your cgi (i.e. requests to http://yourserver.com/edit-img/ are mapped to http://yourserver.com/cgi-bin/image.cgi ) then use the trailing path_info to identify what kind of inmage to create: so http://yourserver.com/edit-img/greyscale/images/foo.gif will return a greyscale version of http://yourserver.com/images/foo.gif, http://yourserver.com/edit-img/resize/80-200/images/foo.gif does the obvious,etc. This is handy for existing images you need to manipulate, obviously. -- As the trials of life continue to take their toll, remember that there is always a future in Computer Maintenance. -- National Lampoon, "Deteriorata" Rasputin :: Jack of All Trades - Master of Nuns