[Bioperl-l] Bio::Graphics output
Niels Larsen
nel at birc.dk
Sun Oct 5 12:49:57 EDT 2003
Hmm .. unless one doesnt like temporary files, which someone have
to come and clean up. The crude piece below does it without, and
with a separate low-overhead image-serving script and a low number
of images per page it would work reasonably well.
Niels
On Friday 03 Oct 2003 6:27 pm, Lincoln Stein wrote:
> Then you have to generate a temporary file and point at it.
>
> Lincoln
>
> On Friday 12 September 2003 03:39 pm, Niels Larsen wrote:
> > > You have to output the image to a file and make an html img tag pointing
> > > to that file. HTH,
> > > Marc
> >
> > Or have a script make it while the page is loaded,
> >
> > <img src="make_image.cgi">
> >
> > That works good for few large images; many mall ones would
> > slow the server.
> >
> > Niels L
#!/usr/bin/env perl
# Place script in document root
use strict;
use warnings;
use GD;
use CGI;
my ( $cgi, $img, $black, $red, $script );
$cgi = new CGI;
print qq (Content-type: text/html\n\n);
if ( $cgi->param('make_image') )
{
$img = new GD::Image(100,100);
$black = $img->colorAllocate( 0,0,0 );
$red = $img->colorAllocate( 255,0,0 );
$img->rectangle( 0,0,99,99,$black );
$img->fill( 50,50,$red );
binmode STDOUT;
print $img->png;
}
else
{
$script = ( split "/", $0 )[-1];
print qq (<img src="/$script?make_image=1">\n);
}
More information about the Bioperl-l
mailing list