(none) imager-devel
/ help / lists / applications / search /
 

RE: printing generated png image

From: Dan Muey (
08465@xyz.molar.is)
Date: Fri 09 May 2003 - 17:09:53 GMT

  • Next message: Dan Muey: "RE: printing generated png image"

    Thanks, I'll give that a go and see how she works!
    I'm sure I'll have one or two more posts before I get this all
    Ironed out.

    Thanks again
    Dan

    > From perldoc Imager::Files (slightly modified)
    >
    > use CGI qw(:standard);
    > $| = 1;
    > binmode STDOUT;
    > my $img =
    > Imager->new(xsize=>400,ysize=>300,channels=>4,type=>'paletted'
    > ,bits=>16)
    > Imager->;
    > .
    > .
    > draw some stuff
    > .
    > .
    > print header(-type=>'image/png');
    > $img->write(type=>'png', fd=>fileno(STDOUT))
    > or die $img->errstr;
    >
    >
    > I use it myself to generate graphs on the fly.
    >
    > re,
    > Simon
    >
    >
    > On Fri, 9 May 2003, Dan Muey wrote:
    >
    > > Hello list,
    > >
    > > I have a script that is generating an image.
    > >
    > > Instead of writing it to a file I'd like to be able to have
    > the script
    > > print the image.
    > >
    > > Foe example :
    > >
    > > If I just read a png file I can then print it like so :
    > >
    > > use CGI qw/:standard/;
    > > use File::Slurp;
    > >
    > > my $png_guts = read_file("./mysuper.png");
    > > print header("image/png");
    > > print $png_guts;
    > >
    > > So how can I take a blank image : ( never opening or using
    > an existing
    > > image file )
    > >
    > > my $img =
    > >
    > Imager->new(xsize=>400,ysize=>300,channels=>4,type=>'paletted',bits=>1
    > > 6);
    > >
    > > ...do what i need to get the image i want
    > > And print the newly generated image to the screen :
    > >
    > > print header("image/png");
    > > print $img;
    > >
    > > How do I print it to the screen?
    > > How to I make it a png image so the png header will work?
    > >
    > > Thanks a bunch! This looks to be a very cool module that
    > I'll end up
    > > using quite a bit!!
    > >
    > > Dan
    > >
    > >
    > >
    >



  •