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

printing generated png image

From: Dan Muey (
Date: Fri 09 May 2003 - 16:48:53 GMT

  • Next message: 08386@xyz.molar.is: "Re: printing generated png image"

    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=>16);

    ...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!!