You don't really provide a lot of context - is this code in a CGI script? are you trying to display it from Tk?
The changes you make to an Imager object won't be displayed or written anywhere until you call the write method.
There's both sample code and documentation showing how to return an image from a CGI script.
If you want to see what an image looks like from the console, for example, if you're fiddling with the code and want to see what you're producing, write the image to a file and then use some sort of image viewer to view the image.
Another option is to use Tk to view the image, but it's kind of clumsy:
#!perl -w use strict; use Tk; use Tk::Photo; use MIME::Base64; use Tk::PNG; use Imager; my $image = Imager->new(xsize=>100, ysize=>100); # draw something simple here, you'll probably do something more comple +x $image->box(filled=>1, color=>'blue'); $image->box(filled=>1, color=>'red', xmin=>20, ymin=>20, xmax=>79, ymax=>79); my $image_data; $image->write(data =>\$image_data, type=>'png') or die "Cannot save image: ", $image->errstr; # supplying binary data didn't work, so we base64 encode it $image_data = encode_base64($image_data); my $main = MainWindow->new; my $tk_image = $main->Photo(-data => $image_data); $main->Label(-image=>$tk_image)->pack; MainLoop;
In reply to Re: Imager drawing question
by tonyc
in thread Imager drawing question
by bradcathey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |