in reply to CGI: Raw image data

You can send the raw image data directly to the browser as long as you know the image type.

use CGI; my $q = CGI->new; my $imgdata = get_image_data(); print $q->header( 'image/jpeg' ); # or image/gif, etc. print $imgdata;

Replies are listed 'Best First'.
Re^2: CGI: Raw image data
by Errto (Vicar) on Apr 29, 2005 at 00:36 UTC
    Don't forget to add
    binmode STDOUT;
    before you print the image data, just to be safe.
Re^2: CGI: Raw image data
by Sprad (Hermit) on Apr 28, 2005 at 23:24 UTC
    Can I do that in the middle of a page, though? I actually need to display several of these images on a page, along with some UI and text.

    ---
    A fair fight is a sign of poor planning.

      For each image you can make the images URL refer to a CGI like the one he gave you so that each image is a call to the CGI.


      ___________
      Eric Hodges
        Just to clarify a little bit:
        <img src="PATH_TO_CGI.cgi?whatever_params_youneed">

      You could use the data: url scheme, but you'll find browser support a little lacking (Internet Explorer is among those browsers without support).

      You'll need to, as previously mentioned, have the user agent make additional requests for each image.