5 samp-tags.cgi - sample CGI that takes an uploaded image to produce a report
9 Copy samp-tags.html to your document tree.
10 Copy samp-tags.cgi to your /cgi-bin
11 Browse to samp-tags.html in your browser
13 Click on "Report Image Tags"
24 my $filename = $cgi->param('image');
26 my $fh = $cgi->upload('image');
30 my $image = Imager->new;
31 if ($image->read(fh=>$fh)) {
32 print "Content-Type: text/plain\n\n";
33 print "File: $filename\n";
34 my @tags = $image->tags;
35 for my $tag (sort { $a->[0] cmp $b->[0] } @tags) {
36 my $name = shift @$tag;
37 print " $name: @$tag\n";
41 error("Cannot read image: ".$image->errstr);
45 error("Incorrect form or input tag - check enctype and that the file upload field is type file");
49 error("No image was supplied");
52 # simple error handler, ideally you'd display the form again with
53 # an error in the right place, but this is a sample
57 print "Content-Type: text/plain\n\nError processing form:\n$msg\n";
63 This is a sample CGI program that accepts an image file from the
66 Please read L<Imager::Cookbook/Parsing an image posted via CGI> for
67 cautions and explanations.
71 Tony Cook <tonyc@cpan.org>