]> git.imager.perl.org - imager.git/blobdiff - Imager.pm
-document that you don't want the FT2 freetype.h in the include path
[imager.git] / Imager.pm
index 8baa2cb00a728441427ee1dd8dc2793786f6134e..a87ccc00512006703b9e355ee9fb048d78c34e91 100644 (file)
--- a/Imager.pm
+++ b/Imager.pm
@@ -1,7 +1,7 @@
 package Imager;
 
 use strict;
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS %formats $DEBUG %filters %DSOs $ERRSTR $fontstate %OPCODES $I2P $FORMATGUESS);
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS %formats $DEBUG %filters %DSOs $ERRSTR $fontstate %OPCODES $I2P $FORMATGUESS $warn_obsolete);
 use IO::File;
 
 use Imager::Color;
@@ -35,7 +35,7 @@ use Imager::Font;
                i_img_setmask
                i_img_getmask
 
-               i_draw
+               i_line
                i_line_aa
                i_box
                i_box_filled
@@ -147,7 +147,7 @@ BEGIN {
   require Exporter;
   require DynaLoader;
 
-  $VERSION = '0.39';
+  $VERSION = '0.43_03';
   @ISA = qw(Exporter DynaLoader);
   bootstrap Imager $VERSION;
 }
@@ -363,6 +363,8 @@ BEGIN {
     };
 
   $FORMATGUESS=\&def_guess_type;
+
+  $warn_obsolete = 1;
 }
 
 #
@@ -380,17 +382,30 @@ BEGIN {
 #  print Dumper(@_);
 #}
 
+sub init_log {
+       m_init_log($_[0],$_[1]);
+       log_entry("Imager $VERSION starting\n", 1);
+}
+
+
 sub init {
   my %parms=(loglevel=>1,@_);
   if ($parms{'log'}) {
     init_log($parms{'log'},$parms{'loglevel'});
   }
 
+  if (exists $parms{'warn_obsolete'}) {
+    $warn_obsolete = $parms{'warn_obsolete'};
+  }
+
 #    if ($parms{T1LIB_CONFIG}) { $ENV{T1LIB_CONFIG}=$parms{T1LIB_CONFIG}; }
 #    if ( $ENV{T1LIB_CONFIG} and ( $fontstate eq 'missing conf' )) {
 #      i_init_fonts();
 #      $fontstate='ok';
 #    }
+  if (exists $parms{'t1log'}) {
+    i_init_fonts($parms{'t1log'});
+  }
 }
 
 END {
@@ -456,6 +471,11 @@ sub _error_as_msg {
 
 sub _color {
   my $arg = shift;
+  # perl 5.6.0 seems to do weird things to $arg if we don't make an 
+  # explicitly stringified copy
+  # I vaguely remember a bug on this on p5p, but couldn't find it
+  # through bugs.perl.org (I had trouble getting it to find any bugs)
+  my $copy = $arg . "";
   my $result;
 
   if (ref $arg) {
@@ -464,10 +484,10 @@ sub _color {
       $result = $arg;
     }
     else {
-      if ($arg =~ /^HASH\(/) {
+      if ($copy =~ /^HASH\(/) {
         $result = Imager::Color->new(%$arg);
       }
-      elsif ($arg =~ /^ARRAY\(/) {
+      elsif ($copy =~ /^ARRAY\(/) {
         if (grep $_ > 1, @$arg) {
           $result = Imager::Color->new(@$arg);
         }
@@ -506,7 +526,12 @@ sub new {
   $self->{ERRSTR}=undef; #
   $self->{DEBUG}=$DEBUG;
   $self->{DEBUG} && print "Initialized Imager\n";
-  if ($hsh{xsize} && $hsh{ysize}) { $self->img_set(%hsh); }
+  if (defined $hsh{xsize} && defined $hsh{ysize}) { 
+    unless ($self->img_set(%hsh)) {
+      $Imager::ERRSTR = $self->{ERRSTR};
+      return;
+    }
+  }
   return $self;
 }
 
@@ -548,46 +573,106 @@ sub paste {
 sub crop {
   my $self=shift;
   unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
-  my %hsh=(left=>0,right=>0,top=>0,bottom=>0,@_);
 
-  my ($w,$h,$l,$r,$b,$t)=($self->getwidth(),$self->getheight(),
-                               @hsh{qw(left right bottom top)});
-  $l=0 if not defined $l;
-  $t=0 if not defined $t;
+  
+  my %hsh=@_;
 
-  $r||=$l+delete $hsh{'width'}    if defined $l and exists $hsh{'width'};
-  $b||=$t+delete $hsh{'height'}   if defined $t and exists $hsh{'height'};
-  $l||=$r-delete $hsh{'width'}    if defined $r and exists $hsh{'width'};
-  $t||=$b-delete $hsh{'height'}   if defined $b and exists $hsh{'height'};
+  my ($w, $h, $l, $r, $b, $t) =
+    @hsh{qw(width height left right bottom top)};
 
-  $r=$self->getwidth if not defined $r;
-  $b=$self->getheight if not defined $b;
+  # work through the various possibilities
+  if (defined $l) {
+    if (defined $w) {
+      $r = $l + $w;
+    }
+    elsif (!defined $r) {
+      $r = $self->getwidth;
+    }
+  }
+  elsif (defined $r) {
+    if (defined $w) {
+      $l = $r - $w;
+    }
+    else {
+      $l = 0;
+    }
+  }
+  elsif (defined $w) {
+    $l = int(0.5+($self->getwidth()-$w)/2);
+    $r = $l + $w;
+  }
+  else {
+    $l = 0;
+    $r = $self->getwidth;
+  }
+  if (defined $t) {
+    if (defined $h) {
+      $b = $t + $h;
+    }
+    elsif (!defined $b) {
+      $b = $self->getheight;
+    }
+  }
+  elsif (defined $b) {
+    if (defined $h) {
+      $t = $b - $h;
+    }
+    else {
+      $t = 0;
+    }
+  }
+  elsif (defined $h) {
+    $t=int(0.5+($self->getheight()-$h)/2);
+    $b=$t+$h;
+  }
+  else {
+    $t = 0;
+    $b = $self->getheight;
+  }
 
   ($l,$r)=($r,$l) if $l>$r;
   ($t,$b)=($b,$t) if $t>$b;
 
-  if ($hsh{'width'}) {
-    $l=int(0.5+($w-$hsh{'width'})/2);
-    $r=$l+$hsh{'width'};
-  } else {
-    $hsh{'width'}=$r-$l;
-  }
-  if ($hsh{'height'}) {
-    $b=int(0.5+($h-$hsh{'height'})/2);
-    $t=$h+$hsh{'height'};
-  } else {
-    $hsh{'height'}=$b-$t;
-  }
+  $l < 0 and $l = 0;
+  $r > $self->getwidth and $r = $self->getwidth;
+  $t < 0 and $t = 0;
+  $b > $self->getheight and $b = $self->getheight;
 
-#    print "l=$l, r=$r, h=$hsh{'width'}\n";
-#    print "t=$t, b=$b, w=$hsh{'height'}\n";
+  if ($l == $r || $t == $b) {
+    $self->_set_error("resulting image would have no content");
+    return;
+  }
 
-  my $dst=Imager->new(xsize=>$hsh{'width'}, ysize=>$hsh{'height'}, channels=>$self->getchannels());
+  my $dst = $self->_sametype(xsize=>$r-$l, ysize=>$b-$t);
 
   i_copyto($dst->{IMG},$self->{IMG},$l,$t,$r,$b,0,0);
   return $dst;
 }
 
+sub _sametype {
+  my ($self, %opts) = @_;
+
+  $self->{IMG} or return $self->_set_error("Not a valid image");
+
+  my $x = $opts{xsize} || $self->getwidth;
+  my $y = $opts{ysize} || $self->getheight;
+  my $channels = $opts{channels} || $self->getchannels;
+  
+  my $out = Imager->new;
+  if ($channels == $self->getchannels) {
+    $out->{IMG} = i_sametype($self->{IMG}, $x, $y);
+  }
+  else {
+    $out->{IMG} = i_sametype_chans($self->{IMG}, $x, $y, $channels);
+  }
+  unless ($out->{IMG}) {
+    $self->{ERRSTR} = $self->_error_as_msg;
+    return;
+  }
+  
+  return $out;
+}
+
 # Sets an image to a certain size and channel number
 # if there was previously data in the image it is discarded
 
@@ -617,6 +702,13 @@ sub img_set {
     $self->{IMG}=Imager::ImgRaw::new($hsh{'xsize'}, $hsh{'ysize'},
                                      $hsh{'channels'});
   }
+
+  unless ($self->{IMG}) {
+    $self->{ERRSTR} = Imager->_error_as_msg();
+    return;
+  }
+
+  $self;
 }
 
 # created a masked version of the current image
@@ -658,9 +750,13 @@ sub to_paletted {
 
   #print "Type ", i_img_type($result->{IMG}), "\n";
 
-  $result->{IMG} or undef $result;
-
-  return $result;
+  if ($result->{IMG}) {
+    return $result;
+  }
+  else {
+    $self->{ERRSTR} = $self->_error_as_msg;
+    return;
+  }
 }
 
 # convert a paletted (or any image) to an 8-bit/channel RGB images
@@ -854,14 +950,30 @@ sub deltag {
   }
 }
 
-my @needseekcb = qw/tiff/;
-my %needseekcb = map { $_, $_ } @needseekcb;
+sub settag {
+  my ($self, %opts) = @_;
+
+  if ($opts{name}) {
+    $self->deltag(name=>$opts{name});
+    return $self->addtag(name=>$opts{name}, value=>$opts{value});
+  }
+  elsif (defined $opts{code}) {
+    $self->deltag(code=>$opts{code});
+    return $self->addtag(code=>$opts{code}, value=>$opts{value});
+  }
+  else {
+    return undef;
+  }
+}
 
 
 sub _get_reader_io {
-  my ($self, $input, $type) = @_;
+  my ($self, $input) = @_;
 
-  if ($input->{fd}) {
+       if ($input->{io}) {
+               return $input->{io}, undef;
+       }
+  elsif ($input->{fd}) {
     return io_new_fd($input->{fd});
   }
   elsif ($input->{fh}) {
@@ -885,8 +997,8 @@ sub _get_reader_io {
     return io_new_buffer($input->{data});
   }
   elsif ($input->{callback} || $input->{readcb}) {
-    if ($needseekcb{$type} && !$input->{seekcb}) {
-      $self->_set_error("Format $type needs a seekcb parameter");
+    if (!$input->{seekcb}) {
+      $self->_set_error("Need a seekcb parameter");
     }
     if ($input->{maxbuffer}) {
       return io_new_cb($input->{writecb},
@@ -918,6 +1030,11 @@ sub _get_writer_io {
       $self->_set_error("Handle in fh option not opened");
       return;
     }
+    # flush it
+    my $oldfh = select($input->{fh});
+    # flush anything that's buffered, and make sure anything else is flushed
+    $| = 1;
+    select($oldfh);
     return io_new_fd($fd);
   }
   elsif ($input->{file}) {
@@ -970,204 +1087,223 @@ sub read {
   # has been there for half a year dude.
   # Look, i just work here, ok?
 
-  if (!$input{'type'} and $input{file}) {
-    $input{'type'}=$FORMATGUESS->($input{file});
-  }
+  my ($IO, $fh) = $self->_get_reader_io(\%input) or return;
+
+  unless ($input{'type'}) {
+               $input{'type'} = i_test_format_probe($IO, -1);
+       }
+
   unless ($input{'type'}) {
-    $self->_set_error('type parameter missing and not possible to guess from extension'); 
+         $self->_set_error('type parameter missing and not possible to guess from extension'); 
     return undef;
   }
-  if (!$formats{$input{'type'}}) {
-    $self->{ERRSTR}='format not supported'; return undef;
-  }
-
-  my %iolready=(jpeg=>1, png=>1, tiff=>1, pnm=>1, raw=>1, bmp=>1, tga=>1, rgb=>1, gif=>1);
-
-  if ($iolready{$input{'type'}}) {
-    # Setup data source
-    my ($IO, $fh) = $self->_get_reader_io(\%input, $input{'type'})
-      or return;
 
-    if ( $input{'type'} eq 'jpeg' ) {
-      ($self->{IMG},$self->{IPTCRAW})=i_readjpeg_wiol( $IO );
-      if ( !defined($self->{IMG}) ) {
-       $self->{ERRSTR}='unable to read jpeg image'; return undef;
-      }
-      $self->{DEBUG} && print "loading a jpeg file\n";
-      return $self;
+  # Setup data source
+  if ( $input{'type'} eq 'jpeg' ) {
+    ($self->{IMG},$self->{IPTCRAW}) = i_readjpeg_wiol( $IO );
+    if ( !defined($self->{IMG}) ) {
+      $self->{ERRSTR}='unable to read jpeg image'; return undef;
     }
+    $self->{DEBUG} && print "loading a jpeg file\n";
+    return $self;
+  }
 
-    if ( $input{'type'} eq 'tiff' ) {
-      $self->{IMG}=i_readtiff_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
-      if ( !defined($self->{IMG}) ) {
-       $self->{ERRSTR}=$self->_error_as_msg(); return undef;
-      }
-      $self->{DEBUG} && print "loading a tiff file\n";
-      return $self;
+  if ( $input{'type'} eq 'tiff' ) {
+    $self->{IMG}=i_readtiff_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
+    if ( !defined($self->{IMG}) ) {
+      $self->{ERRSTR}=$self->_error_as_msg(); return undef;
     }
+    $self->{DEBUG} && print "loading a tiff file\n";
+    return $self;
+  }
 
-    if ( $input{'type'} eq 'pnm' ) {
-      $self->{IMG}=i_readpnm_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
-      if ( !defined($self->{IMG}) ) {
-       $self->{ERRSTR}='unable to read pnm image: '._error_as_msg(); return undef;
-      }
-      $self->{DEBUG} && print "loading a pnm file\n";
-      return $self;
+  if ( $input{'type'} eq 'pnm' ) {
+    $self->{IMG}=i_readpnm_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
+    if ( !defined($self->{IMG}) ) {
+      $self->{ERRSTR}='unable to read pnm image: '._error_as_msg(); return undef;
     }
+    $self->{DEBUG} && print "loading a pnm file\n";
+    return $self;
+  }
 
-    if ( $input{'type'} eq 'png' ) {
-      $self->{IMG}=i_readpng_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
-      if ( !defined($self->{IMG}) ) {
-       $self->{ERRSTR}='unable to read png image';
-       return undef;
-      }
-      $self->{DEBUG} && print "loading a png file\n";
+  if ( $input{'type'} eq 'png' ) {
+    $self->{IMG}=i_readpng_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
+    if ( !defined($self->{IMG}) ) {
+      $self->{ERRSTR}='unable to read png image';
+      return undef;
     }
+    $self->{DEBUG} && print "loading a png file\n";
+  }
 
-    if ( $input{'type'} eq 'bmp' ) {
-      $self->{IMG}=i_readbmp_wiol( $IO );
-      if ( !defined($self->{IMG}) ) {
-       $self->{ERRSTR}=$self->_error_as_msg();
-       return undef;
-      }
-      $self->{DEBUG} && print "loading a bmp file\n";
+  if ( $input{'type'} eq 'bmp' ) {
+    $self->{IMG}=i_readbmp_wiol( $IO );
+    if ( !defined($self->{IMG}) ) {
+      $self->{ERRSTR}=$self->_error_as_msg();
+      return undef;
     }
+    $self->{DEBUG} && print "loading a bmp file\n";
+  }
 
-    if ( $input{'type'} eq 'gif' ) {
-      if ($input{colors} && !ref($input{colors})) {
-       # must be a reference to a scalar that accepts the colour map
-       $self->{ERRSTR} = "option 'colors' must be a scalar reference";
-       return undef;
-      }
-      if ($input{colors}) {
-        my $colors;
-        ($self->{IMG}, $colors) =i_readgif_wiol( $IO );
-        if ($colors) {
-          ${ $input{colors} } = [ map { NC(@$_) } @$colors ];
-        }
-      }
-      else {
-        $self->{IMG} =i_readgif_wiol( $IO );
-      }
-      if ( !defined($self->{IMG}) ) {
-       $self->{ERRSTR}=$self->_error_as_msg();
-       return undef;
+  if ( $input{'type'} eq 'gif' ) {
+    if ($input{colors} && !ref($input{colors})) {
+      # must be a reference to a scalar that accepts the colour map
+      $self->{ERRSTR} = "option 'colors' must be a scalar reference";
+      return undef;
+    }
+    if ($input{colors}) {
+      my $colors;
+      ($self->{IMG}, $colors) =i_readgif_wiol( $IO );
+      if ($colors) {
+       ${ $input{colors} } = [ map { NC(@$_) } @$colors ];
       }
-      $self->{DEBUG} && print "loading a gif file\n";
     }
+    else {
+      $self->{IMG} =i_readgif_wiol( $IO );
+    }
+    if ( !defined($self->{IMG}) ) {
+      $self->{ERRSTR}=$self->_error_as_msg();
+      return undef;
+    }
+    $self->{DEBUG} && print "loading a gif file\n";
+  }
 
-    if ( $input{'type'} eq 'tga' ) {
-      $self->{IMG}=i_readtga_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
-      if ( !defined($self->{IMG}) ) {
-       $self->{ERRSTR}=$self->_error_as_msg();
-       return undef;
-      }
-      $self->{DEBUG} && print "loading a tga file\n";
+  if ( $input{'type'} eq 'tga' ) {
+    $self->{IMG}=i_readtga_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
+    if ( !defined($self->{IMG}) ) {
+      $self->{ERRSTR}=$self->_error_as_msg();
+      return undef;
     }
+    $self->{DEBUG} && print "loading a tga file\n";
+  }
 
-    if ( $input{'type'} eq 'rgb' ) {
-      $self->{IMG}=i_readrgb_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
-      if ( !defined($self->{IMG}) ) {
-       $self->{ERRSTR}=$self->_error_as_msg();
-       return undef;
-      }
-      $self->{DEBUG} && print "loading a tga file\n";
+  if ( $input{'type'} eq 'rgb' ) {
+    $self->{IMG}=i_readrgb_wiol( $IO, -1 ); # Fixme, check if that length parameter is ever needed
+    if ( !defined($self->{IMG}) ) {
+      $self->{ERRSTR}=$self->_error_as_msg();
+      return undef;
     }
+    $self->{DEBUG} && print "loading a tga file\n";
+  }
 
 
-    if ( $input{'type'} eq 'raw' ) {
-      my %params=(datachannels=>3,storechannels=>3,interleave=>1,%input);
+  if ( $input{'type'} eq 'raw' ) {
+    my %params=(datachannels=>3,storechannels=>3,interleave=>1,%input);
 
-      if ( !($params{xsize} && $params{ysize}) ) {
-       $self->{ERRSTR}='missing xsize or ysize parameter for raw';
-       return undef;
-      }
+    if ( !($params{xsize} && $params{ysize}) ) {
+      $self->{ERRSTR}='missing xsize or ysize parameter for raw';
+      return undef;
+    }
 
-      $self->{IMG} = i_readraw_wiol( $IO,
-                                    $params{xsize},
-                                    $params{ysize},
-                                    $params{datachannels},
-                                    $params{storechannels},
-                                    $params{interleave});
-      if ( !defined($self->{IMG}) ) {
-       $self->{ERRSTR}='unable to read raw image';
-       return undef;
-      }
-      $self->{DEBUG} && print "loading a raw file\n";
+    $self->{IMG} = i_readraw_wiol( $IO,
+                                  $params{xsize},
+                                  $params{ysize},
+                                  $params{datachannels},
+                                  $params{storechannels},
+                                  $params{interleave});
+    if ( !defined($self->{IMG}) ) {
+      $self->{ERRSTR}='unable to read raw image';
+      return undef;
     }
+    $self->{DEBUG} && print "loading a raw file\n";
+  }
 
-  } else {
+  return $self;
+}
 
-    # Old code for reference while changing the new stuff
+sub _fix_gif_positions {
+  my ($opts, $opt, $msg, @imgs) = @_;
 
-    if (!$input{'type'} and $input{file}) {
-      $input{'type'}=$FORMATGUESS->($input{file});
-    }
+  my $positions = $opts->{'gif_positions'};
+  my $index = 0;
+  for my $pos (@$positions) {
+    my ($x, $y) = @$pos;
+    my $img = $imgs[$index++];
+    $img->settag(name=>'gif_left', value=>$x);
+    $img->settag(name=>'gif_top', value=>$y) if defined $y;
+  }
+  $$msg .= "replaced with the gif_left and gif_top tags";
+}
 
-    if (!$input{'type'}) {
-      $self->{ERRSTR}='type parameter missing and not possible to guess from extension'; return undef;
-    }
+my %obsolete_opts =
+  (
+   gif_each_palette=>'gif_local_map',
+   interlace       => 'gif_interlace',
+   gif_delays => 'gif_delay',
+   gif_positions => \&_fix_gif_positions,
+   gif_loop_count => 'gif_loop',
+  );
 
-    if (!$formats{$input{'type'}}) {
-      $self->{ERRSTR}='format not supported';
-      return undef;
-    }
+sub _set_opts {
+  my ($self, $opts, $prefix, @imgs) = @_;
 
-    my ($fh, $fd);
-    if ($input{file}) {
-      $fh = new IO::File($input{file},"r");
-      if (!defined $fh) {
-       $self->{ERRSTR}='Could not open file';
-       return undef;
+  for my $opt (keys %$opts) {
+    my $tagname = $opt;
+    if ($obsolete_opts{$opt}) {
+      my $new = $obsolete_opts{$opt};
+      my $msg = "Obsolete option $opt ";
+      if (ref $new) {
+        $new->($opts, $opt, \$msg, @imgs);
       }
-      binmode($fh);
-      $fd = $fh->fileno();
-    }
-
-    if ($input{fd}) {
-      $fd=$input{fd};
-    }
-
-    if ( $input{'type'} eq 'gif' ) {
-      my $colors;
-      if ($input{colors} && !ref($input{colors})) {
-       # must be a reference to a scalar that accepts the colour map
-       $self->{ERRSTR} = "option 'colors' must be a scalar reference";
-       return undef;
+      else {
+        $msg .= "replaced with the $new tag ";
+        $tagname = $new;
       }
-      if (exists $input{data}) {
-       if ($input{colors}) {
-         ($self->{IMG}, $colors) = i_readgif_scalar($input{data});
-       } else {
-         $self->{IMG}=i_readgif_scalar($input{data});
-       }
-      } else {
-       if ($input{colors}) {
-         ($self->{IMG}, $colors) = i_readgif( $fd );
-       } else {
-         $self->{IMG} = i_readgif( $fd )
-       }
+      $msg .= "line ".(caller(2))[2]." of file ".(caller(2))[1];
+      warn $msg if $warn_obsolete && $^W;
+    }
+    next unless $tagname =~ /^\Q$prefix/;
+    my $value = $opts->{$opt};
+    if (ref $value) {
+      if (UNIVERSAL::isa($value, "Imager::Color")) {
+        my $tag = sprintf("color(%d,%d,%d,%d)", $value->rgba);
+        for my $img (@imgs) {
+          $img->settag(name=>$tagname, value=>$tag);
+        }
       }
-      if ($colors) {
-       # we may or may not change i_readgif to return blessed objects...
-       ${ $input{colors} } = [ map { NC(@$_) } @$colors ];
+      elsif (ref($value) eq 'ARRAY') {
+        for my $i (0..$#$value) {
+          my $val = $value->[$i];
+          if (ref $val) {
+            if (UNIVERSAL::isa($val, "Imager::Color")) {
+              my $tag = sprintf("color(%d,%d,%d,%d)", $value->rgba);
+              $i < @imgs and
+                $imgs[$i]->settag(name=>$tagname, value=>$tag);
+            }
+            else {
+              $self->_set_error("Unknown reference type " . ref($value) . 
+                                " supplied in array for $opt");
+              return;
+            }
+          }
+          else {
+            $i < @imgs
+              and $imgs[$i]->settag(name=>$tagname, value=>$val);
+          }
+        }
       }
-      if ( !defined($self->{IMG}) ) {
-       $self->{ERRSTR}= 'reading GIF:'._error_as_msg();
-       return undef;
+      else {
+        $self->_set_error("Unknown reference type " . ref($value) . 
+                          " supplied for $opt");
+        return;
+      }
+    }
+    else {
+      # set it as a tag for every image
+      for my $img (@imgs) {
+        $img->settag(name=>$tagname, value=>$value);
       }
-      $self->{DEBUG} && print "loading a gif file\n";
     }
   }
-  return $self;
+
+  return 1;
 }
 
 # Write an image to file
 sub write {
   my $self = shift;
-  my %input=(jpegquality=>75, 
-            gifquant=>'mc', 
-            lmdither=>6.0, 
+  my %input=(jpegquality=>75,
+            gifquant=>'mc',
+            lmdither=>6.0,
             lmfixed=>[],
             idstring=>"",
             compress=>1,
@@ -1175,8 +1311,8 @@ sub write {
             fax_fine=>1, @_);
   my $rc;
 
-  my %iolready=( tiff=>1, raw=>1, png=>1, pnm=>1, bmp=>1, jpeg=>1, tga=>1, 
-                 gif=>1 ); # this will be SO MUCH BETTER once they are all in there
+  $self->_set_opts(\%input, "i_", $self)
+    or return undef;
 
   unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
 
@@ -1193,84 +1329,102 @@ sub write {
   my ($IO, $fh) = $self->_get_writer_io(\%input, $input{'type'})
     or return undef;
 
-  # this conditional is probably obsolete
-  if ($iolready{$input{'type'}}) {
+  if ($input{'type'} eq 'tiff') {
+    $self->_set_opts(\%input, "tiff_", $self)
+      or return undef;
+    $self->_set_opts(\%input, "exif_", $self)
+      or return undef;
 
-    if ($input{'type'} eq 'tiff') {
-      if (defined $input{class} && $input{class} eq 'fax') {
-       if (!i_writetiff_wiol_faxable($self->{IMG}, $IO, $input{fax_fine})) {
-         $self->{ERRSTR}='Could not write to buffer';
-         return undef;
-       }
-      } else {
-       if (!i_writetiff_wiol($self->{IMG}, $IO)) {
-         $self->{ERRSTR}='Could not write to buffer';
-         return undef;
-       }
-      }
-    } elsif ( $input{'type'} eq 'pnm' ) {
-      if ( ! i_writeppm_wiol($self->{IMG},$IO) ) {
-       $self->{ERRSTR}='unable to write pnm image';
-       return undef;
-      }
-      $self->{DEBUG} && print "writing a pnm file\n";
-    } elsif ( $input{'type'} eq 'raw' ) {
-      if ( !i_writeraw_wiol($self->{IMG},$IO) ) {
-       $self->{ERRSTR}='unable to write raw image';
-       return undef;
-      }
-      $self->{DEBUG} && print "writing a raw file\n";
-    } elsif ( $input{'type'} eq 'png' ) {
-      if ( !i_writepng_wiol($self->{IMG}, $IO) ) {
-       $self->{ERRSTR}='unable to write png image';
-       return undef;
-      }
-      $self->{DEBUG} && print "writing a png file\n";
-    } elsif ( $input{'type'} eq 'jpeg' ) {
-      if ( !i_writejpeg_wiol($self->{IMG}, $IO, $input{jpegquality})) {
-        $self->{ERRSTR} = $self->_error_as_msg();
+    if (defined $input{class} && $input{class} eq 'fax') {
+      if (!i_writetiff_wiol_faxable($self->{IMG}, $IO, $input{fax_fine})) {
+       $self->{ERRSTR}='Could not write to buffer';
        return undef;
       }
-      $self->{DEBUG} && print "writing a jpeg file\n";
-    } elsif ( $input{'type'} eq 'bmp' ) {
-      if ( !i_writebmp_wiol($self->{IMG}, $IO) ) {
-       $self->{ERRSTR}='unable to write bmp image';
+    } else {
+      if (!i_writetiff_wiol($self->{IMG}, $IO)) {
+       $self->{ERRSTR}='Could not write to buffer';
        return undef;
       }
-      $self->{DEBUG} && print "writing a bmp file\n";
-    } elsif ( $input{'type'} eq 'tga' ) {
-
-      if ( !i_writetga_wiol($self->{IMG}, $IO, $input{wierdpack}, $input{compress}, $input{idstring}) ) {
-       $self->{ERRSTR}=$self->_error_as_msg();
-       return undef;
-      }
-      $self->{DEBUG} && print "writing a tga file\n";
-    } elsif ( $input{'type'} eq 'gif' ) {
-      # compatibility with the old interfaces
-      if ($input{gifquant} eq 'lm') {
-        $input{make_colors} = 'addi';
-        $input{translate} = 'perturb';
-        $input{perturb} = $input{lmdither};
-      } elsif ($input{gifquant} eq 'gen') {
-        # just pass options through
-      } else {
-        $input{make_colors} = 'webmap'; # ignored
-        $input{translate} = 'giflib';
-      }
-      $rc = i_writegif_wiol($IO, \%input, $self->{IMG});
     }
+  } elsif ( $input{'type'} eq 'pnm' ) {
+    $self->_set_opts(\%input, "pnm_", $self)
+      or return undef;
+    if ( ! i_writeppm_wiol($self->{IMG},$IO) ) {
+      $self->{ERRSTR}='unable to write pnm image';
+      return undef;
+    }
+    $self->{DEBUG} && print "writing a pnm file\n";
+  } elsif ( $input{'type'} eq 'raw' ) {
+    $self->_set_opts(\%input, "raw_", $self)
+      or return undef;
+    if ( !i_writeraw_wiol($self->{IMG},$IO) ) {
+      $self->{ERRSTR}='unable to write raw image';
+      return undef;
+    }
+    $self->{DEBUG} && print "writing a raw file\n";
+  } elsif ( $input{'type'} eq 'png' ) {
+    $self->_set_opts(\%input, "png_", $self)
+      or return undef;
+    if ( !i_writepng_wiol($self->{IMG}, $IO) ) {
+      $self->{ERRSTR}='unable to write png image';
+      return undef;
+    }
+    $self->{DEBUG} && print "writing a png file\n";
+  } elsif ( $input{'type'} eq 'jpeg' ) {
+    $self->_set_opts(\%input, "jpeg_", $self)
+      or return undef;
+    $self->_set_opts(\%input, "exif_", $self)
+      or return undef;
+    if ( !i_writejpeg_wiol($self->{IMG}, $IO, $input{jpegquality})) {
+      $self->{ERRSTR} = $self->_error_as_msg();
+      return undef;
+    }
+    $self->{DEBUG} && print "writing a jpeg file\n";
+  } elsif ( $input{'type'} eq 'bmp' ) {
+    $self->_set_opts(\%input, "bmp_", $self)
+      or return undef;
+    if ( !i_writebmp_wiol($self->{IMG}, $IO) ) {
+      $self->{ERRSTR}='unable to write bmp image';
+      return undef;
+    }
+    $self->{DEBUG} && print "writing a bmp file\n";
+  } elsif ( $input{'type'} eq 'tga' ) {
+    $self->_set_opts(\%input, "tga_", $self)
+      or return undef;
 
-    if (exists $input{'data'}) {
-      my $data = io_slurp($IO);
-      if (!$data) {
-       $self->{ERRSTR}='Could not slurp from buffer';
-       return undef;
-      }
-      ${$input{data}} = $data;
+    if ( !i_writetga_wiol($self->{IMG}, $IO, $input{wierdpack}, $input{compress}, $input{idstring}) ) {
+      $self->{ERRSTR}=$self->_error_as_msg();
+      return undef;
+    }
+    $self->{DEBUG} && print "writing a tga file\n";
+  } elsif ( $input{'type'} eq 'gif' ) {
+    $self->_set_opts(\%input, "gif_", $self)
+      or return undef;
+    # compatibility with the old interfaces
+    if ($input{gifquant} eq 'lm') {
+      $input{make_colors} = 'addi';
+      $input{translate} = 'perturb';
+      $input{perturb} = $input{lmdither};
+    } elsif ($input{gifquant} eq 'gen') {
+      # just pass options through
+    } else {
+      $input{make_colors} = 'webmap'; # ignored
+      $input{translate} = 'giflib';
+    }
+    if (!i_writegif_wiol($IO, \%input, $self->{IMG})) {
+      $self->{ERRSTR} = $self->_error_as_msg;
+      return;
     }
-    return $self;
   }
 
+  if (exists $input{'data'}) {
+    my $data = io_slurp($IO);
+    if (!$data) {
+      $self->{ERRSTR}='Could not slurp from buffer';
+      return undef;
+    }
+    ${$input{data}} = $data;
+  }
   return $self;
 }
 
@@ -1289,10 +1443,14 @@ sub write_multi {
     $class->_set_error('Usage: Imager->write_multi({ options }, @images)');
     return 0;
   }
+  $class->_set_opts($opts, "i_", @images)
+    or return;
   my @work = map $_->{IMG}, @images;
   my ($IO, $file) = $class->_get_writer_io($opts, $opts->{'type'})
     or return undef;
   if ($opts->{'type'} eq 'gif') {
+    $class->_set_opts($opts, "gif_", @images)
+      or return;
     my $gif_delays = $opts->{gif_delays};
     local $opts->{gif_delays} = $gif_delays;
     if ($opts->{gif_delays} && !ref $opts->{gif_delays}) {
@@ -1304,6 +1462,10 @@ sub write_multi {
     return $res;
   }
   elsif ($opts->{'type'} eq 'tiff') {
+    $class->_set_opts($opts, "tiff_", @images)
+      or return;
+    $class->_set_opts($opts, "exif_", @images)
+      or return;
     my $res;
     $opts->{fax_fine} = 1 unless exists $opts->{fax_fine};
     if ($opts->{'class'} && $opts->{'class'} eq 'fax') {
@@ -1439,6 +1601,12 @@ sub scale {
   my $img = Imager->new();
   my $tmp = Imager->new();
 
+  unless (defined wantarray) {
+    my @caller = caller;
+    warn "scale() called in void context - scale() returns the scaled image at $caller[1] line $caller[2]\n";
+    return;
+  }
+
   unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
 
   if ($opts{xpixels} and $opts{ypixels} and $opts{'type'}) {
@@ -1639,9 +1807,14 @@ sub transform2 {
     $Imager::ERRSTR = Imager::Expr::error();
     return;
   }
+  my $channels = $opts->{channels} || 3;
+  unless ($channels >= 1 && $channels <= 4) {
+    return Imager->_set_error("channels must be an integer between 1 and 4");
+  }
 
   my $img = Imager->new();
-  $img->{IMG} = i_transform2($opts->{width}, $opts->{height}, $code->code(),
+  $img->{IMG} = i_transform2($opts->{width}, $opts->{height}, 
+                            $channels, $code->code(),
                              $code->nregs(), $code->cregs(),
                              [ map { $_->{IMG} } @imgs ]);
   if (!defined $img->{IMG}) {
@@ -1654,12 +1827,19 @@ sub transform2 {
 
 sub rubthrough {
   my $self=shift;
-  my %opts=(tx=>0,ty=>0,@_);
+  my %opts=(tx => 0,ty => 0, @_);
 
   unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
   unless ($opts{src} && $opts{src}->{IMG}) { $self->{ERRSTR}='empty input image for source'; return undef; }
 
-  unless (i_rubthru($self->{IMG}, $opts{src}->{IMG}, $opts{tx},$opts{ty})) {
+  %opts = (src_minx => 0,
+          src_miny => 0,
+          src_maxx => $opts{src}->getwidth(),
+          src_maxy => $opts{src}->getheight(),
+          %opts);
+
+  unless (i_rubthru($self->{IMG}, $opts{src}->{IMG}, $opts{tx}, $opts{ty},
+         $opts{src_minx}, $opts{src_miny}, $opts{src_maxx}, $opts{src_maxy})) {
     $self->{ERRSTR} = $self->_error_as_msg();
     return undef;
   }
@@ -1709,7 +1889,13 @@ sub rotate {
     my $amount = $opts{radians} || $opts{degrees} * 3.1415926535 / 180;
 
     my $result = Imager->new;
-    if ($result->{IMG} = i_rotate_exact($self->{IMG}, $amount)) {
+    if ($opts{back}) {
+      $result->{IMG} = i_rotate_exact($self->{IMG}, $amount, $opts{back});
+    }
+    else {
+      $result->{IMG} = i_rotate_exact($self->{IMG}, $amount);
+    }
+    if ($result->{IMG}) {
       return $result;
     }
     else {
@@ -1718,7 +1904,7 @@ sub rotate {
     }
   }
   else {
-    $self->{ERRSTR} = "Only the 'right' parameter is available";
+    $self->{ERRSTR} = "Only the 'right', 'radians' and 'degrees' parameters are available";
     return undef;
   }
 }
@@ -1732,9 +1918,16 @@ sub matrix_transform {
     my $ysize = $opts{ysize} || $self->getheight;
 
     my $result = Imager->new;
-    $result->{IMG} = i_matrix_transform($self->{IMG}, $xsize, $ysize, 
-                                        $opts{matrix})
-      or return undef;
+    if ($opts{back}) {
+      $result->{IMG} = i_matrix_transform($self->{IMG}, $xsize, $ysize, 
+                                         $opts{matrix}, $opts{back})
+       or return undef;
+    }
+    else {
+      $result->{IMG} = i_matrix_transform($self->{IMG}, $xsize, $ysize, 
+                                         $opts{matrix})
+       or return undef;
+    }
 
     return $result;
   }
@@ -1854,29 +2047,34 @@ sub arc {
   return $self;
 }
 
-# Draws a line from one point to (but not including) the destination point
+# Draws a line from one point to the other
+# the endpoint is set if the endp parameter is set which it is by default.
+# to turn of the endpoint being set use endp=>0 when calling line.
 
 sub line {
   my $self=shift;
   my $dflcl=i_color_new(0,0,0,0);
-  my %opts=(color=>$dflcl,@_);
+  my %opts=(color=>$dflcl,
+           endp => 1,
+           @_);
   unless ($self->{IMG}) { $self->{ERRSTR}='empty input image'; return undef; }
 
   unless (exists $opts{x1} and exists $opts{y1}) { $self->{ERRSTR}='missing begining coord'; return undef; }
   unless (exists $opts{x2} and exists $opts{y2}) { $self->{ERRSTR}='missing ending coord'; return undef; }
 
   my $color = _color($opts{'color'});
-  unless ($color) { 
-    $self->{ERRSTR} = $Imager::ERRSTR; 
-    return; 
+  unless ($color) {
+    $self->{ERRSTR} = $Imager::ERRSTR;
+    return;
   }
+
   $opts{antialias} = $opts{aa} if defined $opts{aa};
   if ($opts{antialias}) {
-    i_line_aa($self->{IMG},$opts{x1}, $opts{y1}, $opts{x2}, $opts{y2}, 
-              $color);
+    i_line_aa($self->{IMG},$opts{x1}, $opts{y1}, $opts{x2}, $opts{y2},
+              $color, $opts{endp});
   } else {
-    i_draw($self->{IMG},$opts{x1}, $opts{y1}, $opts{x2}, $opts{y2}, 
-           $color);
+    i_line($self->{IMG},$opts{x1}, $opts{y1}, $opts{x2}, $opts{y2},
+           $color, $opts{endp});
   }
   return $self;
 }
@@ -1908,14 +2106,14 @@ sub polyline {
   if ($opts{antialias}) {
     for $pt(@points) {
       if (defined($ls)) { 
-        i_line_aa($self->{IMG},$ls->[0],$ls->[1],$pt->[0],$pt->[1],$color);
+        i_line_aa($self->{IMG},$ls->[0],$ls->[1],$pt->[0],$pt->[1],$color, 1);
       }
       $ls=$pt;
     }
   } else {
     for $pt(@points) {
       if (defined($ls)) { 
-        i_draw($self->{IMG},$ls->[0],$ls->[1],$pt->[0],$pt->[1],$color);
+        i_line($self->{IMG},$ls->[0],$ls->[1],$pt->[0],$pt->[1],$color,1);
       }
       $ls=$pt;
     }
@@ -2000,6 +2198,7 @@ sub polybezier {
 sub flood_fill {
   my $self = shift;
   my %opts = ( color=>Imager::Color->new(255, 255, 255), @_ );
+  my $rc;
 
   unless (exists $opts{'x'} && exists $opts{'y'}) {
     $self->{ERRSTR} = "missing seed x and y parameters";
@@ -2015,32 +2214,115 @@ sub flood_fill {
         return;
       }
     }
-    i_flood_cfill($self->{IMG}, $opts{'x'}, $opts{'y'}, $opts{fill}{fill});
+    $rc = i_flood_cfill($self->{IMG}, $opts{'x'}, $opts{'y'}, $opts{fill}{fill});
   }
   else {
     my $color = _color($opts{'color'});
-    unless ($color) { 
-      $self->{ERRSTR} = $Imager::ERRSTR; 
-      return; 
+    unless ($color) {
+      $self->{ERRSTR} = $Imager::ERRSTR;
+      return;
     }
-    i_flood_fill($self->{IMG}, $opts{'x'}, $opts{'y'}, $color);
+    $rc = i_flood_fill($self->{IMG}, $opts{'x'}, $opts{'y'}, $color);
   }
-
-  $self;
+  if ($rc) { $self; } else { $self->{ERRSTR} = $self->_error_as_msg(); return (); }
 }
 
-# make an identity matrix of the given size
-sub _identity {
-  my ($size) = @_;
+sub setpixel {
+  my $self = shift;
 
-  my $matrix = [ map { [ (0) x $size ] } 1..$size ];
-  for my $c (0 .. ($size-1)) {
-    $matrix->[$c][$c] = 1;
+  my %opts = ( color=>$self->{fg} || NC(255, 255, 255), @_);
+
+  unless (exists $opts{'x'} && exists $opts{'y'}) {
+    $self->{ERRSTR} = 'missing x and y parameters';
+    return undef;
   }
-  return $matrix;
-}
 
-# general function to convert an image
+  my $x = $opts{'x'};
+  my $y = $opts{'y'};
+  my $color = _color($opts{color})
+    or return undef;
+  if (ref $x && ref $y) {
+    unless (@$x == @$y) {
+      $self->{ERRSTR} = 'length of x and y mismatch';
+      return undef;
+    }
+    if ($color->isa('Imager::Color')) {
+      for my $i (0..$#{$opts{'x'}}) {
+        i_ppix($self->{IMG}, $x->[$i], $y->[$i], $color);
+      }
+    }
+    else {
+      for my $i (0..$#{$opts{'x'}}) {
+        i_ppixf($self->{IMG}, $x->[$i], $y->[$i], $color);
+      }
+    }
+  }
+  else {
+    if ($color->isa('Imager::Color')) {
+      i_ppix($self->{IMG}, $x, $y, $color);
+    }
+    else {
+      i_ppixf($self->{IMG}, $x, $y, $color);
+    }
+  }
+
+  $self;
+}
+
+sub getpixel {
+  my $self = shift;
+
+  my %opts = ( "type"=>'8bit', @_);
+
+  unless (exists $opts{'x'} && exists $opts{'y'}) {
+    $self->{ERRSTR} = 'missing x and y parameters';
+    return undef;
+  }
+
+  my $x = $opts{'x'};
+  my $y = $opts{'y'};
+  if (ref $x && ref $y) {
+    unless (@$x == @$y) {
+      $self->{ERRSTR} = 'length of x and y mismatch';
+      return undef;
+    }
+    my @result;
+    if ($opts{"type"} eq '8bit') {
+      for my $i (0..$#{$opts{'x'}}) {
+        push(@result, i_get_pixel($self->{IMG}, $x->[$i], $y->[$i]));
+      }
+    }
+    else {
+      for my $i (0..$#{$opts{'x'}}) {
+        push(@result, i_gpixf($self->{IMG}, $x->[$i], $y->[$i]));
+      }
+    }
+    return wantarray ? @result : \@result;
+  }
+  else {
+    if ($opts{"type"} eq '8bit') {
+      return i_get_pixel($self->{IMG}, $x, $y);
+    }
+    else {
+      return i_gpixf($self->{IMG}, $x, $y);
+    }
+  }
+
+  $self;
+}
+
+# make an identity matrix of the given size
+sub _identity {
+  my ($size) = @_;
+
+  my $matrix = [ map { [ (0) x $size ] } 1..$size ];
+  for my $c (0 .. ($size-1)) {
+    $matrix->[$c][$c] = 1;
+  }
+  return $matrix;
+}
+
+# general function to convert an image
 sub convert {
   my ($self, %opts) = @_;
   my $matrix;
@@ -2164,6 +2446,27 @@ sub map {
   return $self;
 }
 
+sub difference {
+  my ($self, %opts) = @_;
+
+  defined $opts{mindist} or $opts{mindist} = 0;
+
+  defined $opts{other}
+    or return $self->_set_error("No 'other' parameter supplied");
+  defined $opts{other}{IMG}
+    or return $self->_set_error("No image data in 'other' image");
+
+  $self->{IMG}
+    or return $self->_set_error("No image data");
+
+  my $result = Imager->new;
+  $result->{IMG} = i_diff_image($self->{IMG}, $opts{other}{IMG}, 
+                                $opts{mindist})
+    or return $self->_set_error($self->_error_as_msg());
+
+  return $result;
+}
+
 # destructive border - image is shrunk by one pixel all around
 
 sub border {
@@ -2278,6 +2581,7 @@ sub _set_error {
   else {
     $ERRSTR = $msg;
   }
+  return;
 }
 
 # Default guess for the type of an image from extension
@@ -2378,1548 +2682,306 @@ Imager - Perl extension for Generating 24 bit Images
 
 =head1 SYNOPSIS
 
-  use Imager;
-
-  $img = Imager->new();
-  $img->open(file=>'image.ppm',type=>'pnm')
-    || print "failed: ",$img->{ERRSTR},"\n";
-  $scaled=$img->scale(xpixels=>400,ypixels=>400);
-  $scaled->write(file=>'sc_image.ppm',type=>'pnm')
-    || print "failed: ",$scaled->{ERRSTR},"\n";
-
-=head1 DESCRIPTION
-
-Imager is a module for creating and altering images - It is not meant
-as a replacement or a competitor to ImageMagick or GD. Both are
-excellent packages and well supported.
-
-=head2 Overview of documentation
-
-=over
-
-=item Imager
-
-This document - Table of Contents, Example and Overview
-
-=item Imager::ImageTypes
-
-Direct type/virtual images, RGB(A)/paletted images, 8/16/double
-bits/channel, image tags, and channel masks.
-
-=item Imager::Files
-
-IO interaction, reading/writing images, format specific tags.
-
-=item Imager::Draw
-
-Drawing Primitives, lines boxes, circles, flood fill.
-
-=item Imager::Color
-
-Color specification.
-
-=item Imager::Font
-
-General font rendering.
-
-=item Imager::Transformations
-
-Copying, scaling, cropping, flipping, blending, pasting, [convert and map.]
-
-=item Imager::Engines
-
-transform2 and matrix_transform.
-
-=item Imager::Filters
-
-Filters, sharpen, blur, noise, convolve etc. and plugins.
-
-=item Imager::Expr
-
-Expressions for evaluation engine used by transform2().
-
-=item Imager::Matrix2d
-
-Helper class for affine transformations.
-
-=item Imager::Fountain
-
-Helper for making gradient profiles.
-
-=back
-
-
-
-
-
-
-
-
-Almost all functions take the parameters in the hash fashion.
-Example:
-
-  $img->open(file=>'lena.png',type=>'png');
-
-or just:
-
-  $img->open(file=>'lena.png');
-
-=head2 Basic concept
-
-An Image object is created with C<$img = Imager-E<gt>new()> Should
-this fail for some reason an explanation can be found in
-C<$Imager::ERRSTR> usually error messages are stored in
-C<$img-E<gt>{ERRSTR}>, but since no object is created this is the only
-way to give back errors.  C<$Imager::ERRSTR> is also used to report
-all errors not directly associated with an image object. Examples:
-
-  $img=Imager->new(); # This is an empty image (size is 0 by 0)
-  $img->open(file=>'lena.png',type=>'png'); # initializes from file
-
-or if you want to create an empty image:
-
-  $img=Imager->new(xsize=>400,ysize=>300,channels=>4);
-
-This example creates a completely black image of width 400 and
-height 300 and 4 channels.
-
-If you have an existing image, use img_set() to change it's dimensions
-- this will destroy any existing image data:
-
-  $img->img_set(xsize=>500, ysize=>500, channels=>4);
-
-To create paletted images, set the 'type' parameter to 'paletted':
-
-  $img = Imager->new(xsize=>200, ysize=>200, channels=>3, type=>'paletted');
-
-which creates an image with a maxiumum of 256 colors, which you can
-change by supplying the C<maxcolors> parameter.
-
-You can create a new paletted image from an existing image using the
-to_paletted() method:
-
- $palimg = $img->to_paletted(\%opts)
-
-where %opts contains the options specified under L<Quantization options>.
-
-You can convert a paletted image (or any image) to an 8-bit/channel
-RGB image with:
-
-  $rgbimg = $img->to_rgb8;
-
-Warning: if you draw on a paletted image with colors that aren't in
-the palette, the image will be internally converted to a normal image.
-
-For improved color precision you can use the bits parameter to specify
-16 bit per channel:
-
-  $img = Imager->new(xsize=>200, ysize=>200, channels=>3, bits=>16);
-
-or for even more precision:
-
-  $img = Imager->new(xsize=>200, ysize=>200, channels=>3, bits=>'double');
-
-to get an image that uses a double for each channel.
-
-Note that as of this writing all functions should work on images with
-more than 8-bits/channel, but many will only work at only
-8-bit/channel precision.
-
-Currently only 8-bit, 16-bit, and double per channel image types are
-available, this may change later.
-
-Color objects are created by calling the Imager::Color->new()
-method:
-
-  $color = Imager::Color->new($red, $green, $blue);
-  $color = Imager::Color->new($red, $green, $blue, $alpha);
-  $color = Imager::Color->new("#C0C0FF"); # html color specification
-
-This object can then be passed to functions that require a color parameter.
-
-Coordinates in Imager have the origin in the upper left corner.  The
-horizontal coordinate increases to the right and the vertical
-downwards.
-
-=head2 Reading and writing images
-
-You can read and write a variety of images formats, assuming you have
-the appropriate libraries, and images can be read or written to/from
-files, file handles, file descriptors, scalars, or through callbacks.
-
-To see which image formats Imager is compiled to support the following
-code snippet is sufficient:
-
-  use Imager;
-  print join " ", keys %Imager::formats;
-
-This will include some other information identifying libraries rather
-than file formats.
-
-Reading writing to and from files is simple, use the C<read()>
-method to read an image:
-
-  my $img = Imager->new;
-  $img->read(file=>$filename, type=>$type)
-    or die "Cannot read $filename: ", $img->errstr;
-
-and the C<write()> method to write an image:
-
-  $img->write(file=>$filename, type=>$type)
-    or die "Cannot write $filename: ", $img->errstr;
-
-If the I<filename> includes an extension that Imager recognizes, then
-you don't need the I<type>, but you may want to provide one anyway.
-Imager currently does not check the files magic to determine the
-format.  It is possible to override the method for determining the 
-filetype from the filename.  If the data is given in another form than
-a file name a 
-
-When you read an image, Imager may set some tags, possibly including
-information about the spatial resolution, textual information, and
-animation information.  See L</Tags> for specifics.
-
-When reading or writing you can specify one of a variety of sources or
-targets:
-
-=over
-
-=item file
-
-The C<file> parameter is the name of the image file to be written to
-or read from.  If Imager recognizes the extension of the file you do
-not need to supply a C<type>.
-
-=item fh
-
-C<fh> is a file handle, typically either returned from
-C<<IO::File->new()>>, or a glob from an C<open> call.  You should call
-C<binmode> on the handle before passing it to Imager.
-
-=item fd
-
-C<fd> is a file descriptor.  You can get this by calling the
-C<fileno()> function on a file handle, or by using one of the standard
-file descriptor numbers.
-
-=item data
-
-When reading data, C<data> is a scalar containing the image file data,
-when writing, C<data> is a reference to the scalar to save the image
-file data too.  For GIF images you will need giflib 4 or higher, and
-you may need to patch giflib to use this option for writing.
-
-=item callback
-
-Imager will make calls back to your supplied coderefs to read, write
-and seek from/to/through the image file.
-
-When reading from a file you can use either C<callback> or C<readcb>
-to supply the read callback, and when writing C<callback> or
-C<writecb> to supply the write callback.
-
-When writing you can also supply the C<maxbuffer> option to set the
-maximum amount of data that will be buffered before your write
-callback is called.  Note: the amount of data supplied to your
-callback can be smaller or larger than this size.
-
-The read callback is called with 2 parameters, the minimum amount of
-data required, and the maximum amount that Imager will store in it's C
-level buffer.  You may want to return the minimum if you have a slow
-data source, or the maximum if you have a fast source and want to
-prevent many calls to your perl callback.  The read data should be
-returned as a scalar.
-
-Your write callback takes exactly one parameter, a scalar containing
-the data to be written.  Return true for success.
-
-The seek callback takes 2 parameters, a I<POSITION>, and a I<WHENCE>,
-defined in the same way as perl's seek function.
-
-You can also supply a C<closecb> which is called with no parameters
-when there is no more data to be written.  This could be used to flush
-buffered data.
-
-=back
-
-C<$img-E<gt>read()> generally takes two parameters, 'file' and 'type'.
-If the type of the file can be determined from the suffix of the file
-it can be omitted.  Format dependant parameters are: For images of
-type 'raw' two extra parameters are needed 'xsize' and 'ysize', if the
-'channel' parameter is omitted for type 'raw' it is assumed to be 3.
-gif and png images might have a palette are converted to truecolor bit
-when read.  Alpha channel is preserved for png images irregardless of
-them being in RGB or gray colorspace.  Similarly grayscale jpegs are
-one channel images after reading them.  For jpeg images the iptc
-header information (stored in the APP13 header) is avaliable to some
-degree. You can get the raw header with C<$img-E<gt>{IPTCRAW}>, but
-you can also retrieve the most basic information with
-C<%hsh=$img-E<gt>parseiptc()> as always patches are welcome.  pnm has no 
-extra options. Examples:
-
-  $img = Imager->new();
-  $img->read(file=>"cover.jpg") or die $img->errstr; # gets type from name
-
-  $img = Imager->new();
-  { local(*FH,$/); open(FH,"file.gif") or die $!; $a=<FH>; }
-  $img->read(data=>$a,type=>'gif') or die $img->errstr;
-
-The second example shows how to read an image from a scalar, this is
-usefull if your data originates from somewhere else than a filesystem
-such as a database over a DBI connection.
-
-When writing to a tiff image file you can also specify the 'class'
-parameter, which can currently take a single value, "fax".  If class
-is set to fax then a tiff image which should be suitable for faxing
-will be written.  For the best results start with a grayscale image.
-By default the image is written at fine resolution you can override
-this by setting the "fax_fine" parameter to 0.
-
-If you are reading from a gif image file, you can supply a 'colors'
-parameter which must be a reference to a scalar.  The referenced
-scalar will receive an array reference which contains the colors, each
-represented as an Imager::Color object.
-
-If you already have an open file handle, for example a socket or a
-pipe, you can specify the 'fd' parameter instead of supplying a
-filename.  Please be aware that you need to use fileno() to retrieve
-the file descriptor for the file:
-
-  $img->read(fd=>fileno(FILE), type=>'gif') or die $img->errstr;
-
-For writing using the 'fd' option you will probably want to set $| for
-that descriptor, since the writes to the file descriptor bypass Perl's
-(or the C libraries) buffering.  Setting $| should avoid out of order
-output.  For example a common idiom when writing a CGI script is:
-
-  # the $| _must_ come before you send the content-type
-  $| = 1;
-  print "Content-Type: image/jpeg\n\n";
-  $img->write(fd=>fileno(STDOUT), type=>'jpeg') or die $img->errstr;
-
-*Note that load() is now an alias for read but will be removed later*
-
-C<$img-E<gt>write> has the same interface as C<read()>.  The earlier
-comments on C<read()> for autodetecting filetypes apply.  For jpegs
-quality can be adjusted via the 'jpegquality' parameter (0-100).  The
-number of colorplanes in gifs are set with 'gifplanes' and should be
-between 1 (2 color) and 8 (256 colors).  It is also possible to choose
-between two quantizing methods with the parameter 'gifquant'. If set
-to mc it uses the mediancut algorithm from either giflibrary. If set
-to lm it uses a local means algorithm. It is then possible to give
-some extra settings. lmdither is the dither deviation amount in pixels
-(manhattan distance).  lmfixed can be an array ref who holds an array
-of Imager::Color objects.  Note that the local means algorithm needs
-much more cpu time but also gives considerable better results than the
-median cut algorithm.
-
-When storing targa images rle compression can be activated with the
-'compress' parameter, the 'idstring' parameter can be used to set the
-targa comment field and the 'wierdpack' option can be used to use the
-15 and 16 bit targa formats for rgb and rgba data.  The 15 bit format
-has 5 of each red, green and blue.  The 16 bit format in addition
-allows 1 bit of alpha.  The most significant bits are used for each
-channel.
-
-Currently just for gif files, you can specify various options for the
-conversion from Imager's internal RGB format to the target's indexed
-file format.  If you set the gifquant option to 'gen', you can use the
-options specified under L<Quantization options>.
-
-To see what Imager is compiled to support the following code snippet
-is sufficient:
+  # Thumbnail example
 
+  #!/usr/bin/perl -w
+  use strict;
   use Imager;
-  print "@{[keys %Imager::formats]}";
-
-When reading raw images you need to supply the width and height of the
-image in the xsize and ysize options:
-
-  $img->read(file=>'foo.raw', xsize=>100, ysize=>100)
-    or die "Cannot read raw image\n";
-
-If your input file has more channels than you want, or (as is common),
-junk in the fourth channel, you can use the datachannels and
-storechannels options to control the number of channels in your input
-file and the resulting channels in your image.  For example, if your
-input image uses 32-bits per pixel with red, green, blue and junk
-values for each pixel you could do:
-
-  $img->read(file=>'foo.raw', xsize=>100, ysize=>100, datachannels=>4,
-            storechannels=>3)
-    or die "Cannot read raw image\n";
-
-Normally the raw image is expected to have the value for channel 1
-immediately following channel 0 and channel 2 immediately following
-channel 1 for each pixel.  If your input image has all the channel 0
-values for the first line of the image, followed by all the channel 1
-values for the first line and so on, you can use the interleave option:
-
-  $img->read(file=>'foo.raw', xsize=100, ysize=>100, interleave=>1)
-    or die "Cannot read raw image\n";
-
-=head2 Multi-image files
-
-Currently just for gif files, you can create files that contain more
-than one image.
-
-To do this:
-
-  Imager->write_multi(\%opts, @images)
-
-Where %opts describes 4 possible types of outputs:
-
-=over 5
-
-=item type
-
-This is C<gif> for gif animations.
-
-=item callback
-
-A code reference which is called with a single parameter, the data to
-be written.  You can also specify $opts{maxbuffer} which is the
-maximum amount of data buffered.  Note that there can be larger writes
-than this if the file library writes larger blocks.  A smaller value
-maybe useful for writing to a socket for incremental display.
 
-=item fd
+  die "Usage: thumbmake.pl filename\n" if !-f $ARGV[0];
+  my $file = shift;
 
-The file descriptor to save the images to.
+  my $format;
 
-=item file
-
-The name of the file to write to.
-
-%opts may also include the keys from L<Gif options> and L<Quantization
-options>.
+  my $img = Imager->new();
+  # see Imager::Files for information on the open() method
+  $img->open(file=>$file) or die $img->errstr();
 
-=back
+  $file =~ s/\.[^.]*$//;
 
-You must also specify the file format using the 'type' option.
+  # Create smaller version
+  # documented in Imager::Transformations
+  my $thumb = $img->scale(scalefactor=>.3);
 
-The current aim is to support other multiple image formats in the
-future, such as TIFF, and to support reading multiple images from a
-single file.
+  # Autostretch individual channels
+  $thumb->filter(type=>'autolevels');
 
-A simple example:
+  # try to save in one of these formats
+  SAVE:
 
-    my @images;
-    # ... code to put images in @images
-    Imager->write_multi({type=>'gif',
-                        file=>'anim.gif',
-                        gif_delays=>[ (10) x @images ] },
-                       @images)
-    or die "Oh dear!";
+  for $format ( qw( png gif jpg tiff ppm ) ) {
+    # Check if given format is supported
+    if ($Imager::formats{$format}) {
+      $file.="_low.$format";
+      print "Storing image as: $file\n";
+      # documented in Imager::Files
+      $thumb->write(file=>$file) or
+        die $thumb->errstr;
+      last SAVE;
+    }
+  }
 
-You can read multi-image files (currently only GIF files) using the
-read_multi() method:
+=head1 DESCRIPTION
 
-  my @imgs = Imager->read_multi(file=>'foo.gif')
-    or die "Cannot read images: ",Imager->errstr;
+Imager is a module for creating and altering images.  It can read and
+write various image formats, draw primitive shapes like lines,and
+polygons, blend multiple images together in various ways, scale, crop,
+render text and more.
 
-The possible parameters for read_multi() are:
+=head2 Overview of documentation
 
 =over
 
-=item file
-
-The name of the file to read in.
-
-=item fh
-
-A filehandle to read in.  This can be the name of a filehandle, but it
-will need the package name, no attempt is currently made to adjust
-this to the caller's package.
-
-=item fd
-
-The numeric file descriptor of an open file (or socket).
-
-=item callback
-
-A function to be called to read in data, eg. reading a blob from a
-database incrementally.
-
-=item data
-
-The data of the input file in memory.
-
-=item type
-
-The type of file.  If the file is parameter is given and provides
-enough information to guess the type, then this parameter is optional.
-
-=back
-
-Note: you cannot use the callback or data parameter with giflib
-versions before 4.0.
-
-When reading from a GIF file with read_multi() the images are returned
-as paletted images.
-
-=head2 Gif options
-
-These options can be specified when calling write_multi() for gif
-files, when writing a single image with the gifquant option set to
-'gen', or for direct calls to i_writegif_gen and i_writegif_callback.
-
-Note that some viewers will ignore some of these options
-(gif_user_input in particular).
-
-=over 4
-
-=item gif_each_palette
-
-Each image in the gif file has it's own palette if this is non-zero.
-All but the first image has a local colour table (the first uses the
-global colour table.
-
-=item interlace
-
-The images are written interlaced if this is non-zero.
-
-=item gif_delays
-
-A reference to an array containing the delays between images, in 1/100
-seconds.
-
-If you want the same delay for every frame you can simply set this to
-the delay in 1/100 seconds.
-
-=item gif_user_input
-
-A reference to an array contains user input flags.  If the given flag
-is non-zero the image viewer should wait for input before displaying
-the next image.
-
-=item gif_disposal
-
-A reference to an array of image disposal methods.  These define what
-should be done to the image before displaying the next one.  These are
-integers, where 0 means unspecified, 1 means the image should be left
-in place, 2 means restore to background colour and 3 means restore to
-the previous value.
-
-=item gif_tran_color
+=item *
 
-A reference to an Imager::Color object, which is the colour to use for
-the palette entry used to represent transparency in the palette.  You
-need to set the transp option (see L<Quantization options>) for this
-value to be used.
+Imager - This document - Synopsis Example, Table of Contents and
+Overview.
 
-=item gif_positions
+=item *
 
-A reference to an array of references to arrays which represent screen
-positions for each image.
+L<Imager::ImageTypes> - Basics of constructing image objects with
+C<new()>: Direct type/virtual images, RGB(A)/paletted images,
+8/16/double bits/channel, color maps, channel masks, image tags, color
+quantization.  Also discusses basic image information methods.
 
-=item gif_loop_count
+=item *
 
-If this is non-zero the Netscape loop extension block is generated,
-which makes the animation of the images repeat.
+L<Imager::Files> - IO interaction, reading/writing images, format
+specific tags.
 
-This is currently unimplemented due to some limitations in giflib.
+=item *
 
-=item gif_eliminate_unused
+L<Imager::Draw> - Drawing Primitives, lines, boxes, circles, arcs,
+flood fill.
 
-If this is true, when you write a paletted image any unused colors
-will be eliminated from its palette.  This is set by default.
+=item *
 
-=back
+L<Imager::Color> - Color specification.
 
-=head2 Quantization options
+=item *
 
-These options can be specified when calling write_multi() for gif
-files, when writing a single image with the gifquant option set to
-'gen', or for direct calls to i_writegif_gen and i_writegif_callback.
+L<Imager::Fill> - Fill pattern specification.
 
-=over 4
+=item *
 
-=item colors
+L<Imager::Font> - General font rendering, bounding boxes and font
+metrics.
 
-A arrayref of colors that are fixed.  Note that some color generators
-will ignore this.
+=item *
 
-=item transp
+L<Imager::Transformations> - Copying, scaling, cropping, flipping,
+blending, pasting, convert and map.
 
-The type of transparency processing to perform for images with an
-alpha channel where the output format does not have a proper alpha
-channel (eg. gif).  This can be any of:
+=item *
 
-=over 4
+L<Imager::Engines> - Programmable transformations through
+C<transform()>, C<transform2()> and C<matrix_transform()>.
 
-=item none
+=item *
 
-No transparency processing is done. (default)
+L<Imager::Filters> - Filters, sharpen, blur, noise, convolve etc. and
+filter plugins.
 
-=item threshold
+=item *
 
-Pixels more transparent that tr_threshold are rendered as transparent.
+L<Imager::Expr> - Expressions for evaluation engine used by
+transform2().
 
-=item errdiff
+=item *
 
-An error diffusion dither is done on the alpha channel.  Note that
-this is independent of the translation performed on the colour
-channels, so some combinations may cause undesired artifacts.
+L<Imager::Matrix2d> - Helper class for affine transformations.
 
-=item ordered
+=item *
 
-The ordered dither specified by tr_orddith is performed on the alpha
-channel.
+L<Imager::Fountain> - Helper for making gradient profiles.
 
 =back
 
-This will only be used if the image has an alpha channel, and if there
-is space in the palette for a transparency colour.
-
-=item tr_threshold
+=head2 Basic Overview
 
-The highest alpha value at which a pixel will be made transparent when
-transp is 'threshold'. (0-255, default 127)
+An Image object is created with C<$img = Imager-E<gt>new()>.
+Examples:
 
-=item tr_errdiff
+  $img=Imager->new();                         # create empty image
+  $img->open(file=>'lena.png',type=>'png') or # read image from file
+     die $img->errstr();                      # give an explanation
+                                              # if something failed
 
-The type of error diffusion to perform on the alpha channel when
-transp is 'errdiff'.  This can be any defined error diffusion type
-except for custom (see errdiff below).
-
-=item tr_orddith
+or if you want to create an empty image:
 
-The type of ordered dither to perform on the alpha channel when transp
-is 'ordered'.  Possible values are:
+  $img=Imager->new(xsize=>400,ysize=>300,channels=>4);
 
-=over 4
+This example creates a completely black image of width 400 and height
+300 and 4 channels.
 
-=item random
+When an operation fails which can be directly associated with an image
+the error message is stored can be retrieved with
+C<$img-E<gt>errstr()>.
 
-A semi-random map is used.  The map is the same each time.
+In cases where no image object is associated with an operation
+C<$Imager::ERRSTR> is used to report errors not directly associated
+with an image object.  You can also call C<Imager->errstr> to get this
+value.
 
-=item dot8
+The C<Imager-E<gt>new> method is described in detail in
+L<Imager::ImageTypes>.
 
-8x8 dot dither.
+=head1 METHOD INDEX
 
-=item dot4
+Where to find information on methods for Imager class objects.
 
-4x4 dot dither
+addcolors() -  L<Imager::ImageTypes>
 
-=item hline
+addtag() -  L<Imager::ImageTypes> - add image tags
 
-horizontal line dither.
+arc() - L<Imager::Draw/arc>
 
-=item vline
+bits() - L<Imager::ImageTypes> - number of bits per sample for the
+image
 
-vertical line dither.
+box() - L<Imager::Draw/box>
 
-=item "/line"
+circle() - L<Imager::Draw/circle>
 
-=item slashline
+convert() - L<Imager::Transformations/"Color transformations"> -
+transform the color space
 
-diagonal line dither
+copy() - L<Imager::Transformations/copy>
 
-=item '\line'
+crop() - L<Imager::Transformations/crop> - extract part of an image
 
-=item backline
+deltag() -  L<Imager::ImageTypes> - delete image tags
 
-diagonal line dither
+difference() - L<Imager::Filters/"Image Difference">
 
-=item tiny
+errstr() - L<Imager/"Basic Overview">
 
-dot matrix dither (currently the default).  This is probably the best
-for displays (like web pages).
+filter() - L<Imager::Filters>
 
-=item custom
+findcolor() - L<Imager::ImageTypes> - search the image palette, if it
+has one
 
-A custom dither matrix is used - see tr_map
+flip() - L<Imager::Transformations/flip>
 
-=back
+flood_fill() - L<Imager::Draw/flood_fill>
 
-=item tr_map
+getchannels() -  L<Imager::ImageTypes>
 
-When tr_orddith is custom this defines an 8 x 8 matrix of integers
-representing the transparency threshold for pixels corresponding to
-each position.  This should be a 64 element array where the first 8
-entries correspond to the first row of the matrix.  Values should be
-betweern 0 and 255.
+getcolorcount() -  L<Imager::ImageTypes>
 
-=item make_colors
+getcolors() - L<Imager::ImageTypes> - get colors from the image
+palette, if it has one
 
-Defines how the quantization engine will build the palette(s).
-Currently this is ignored if 'translate' is 'giflib', but that may
-change.  Possible values are:
+getheight() - L<Imager::ImageTypes>
 
-=over 4
+getpixel() - L<Imager::Draw/setpixel and getpixel>
 
-=item none
+getwidth() - L<Imager::ImageTypes>
 
-Only colors supplied in 'colors' are used.
+img_set() - L<Imager::ImageTypes>
 
-=item webmap
+line() - L<Imager::Draw/line>
 
-The web color map is used (need url here.)
+map() - L<Imager::Transformations/"Color Mappings"> - remap color
+channel values
 
-=item addi
+masked() -  L<Imager::ImageTypes> - make a masked image
 
-The original code for generating the color map (Addi's code) is used.
+matrix_transform() - L<Imager::Engines/"Matrix Transformations">
 
-=back
+new() - L<Imager::ImageTypes>
 
-Other methods may be added in the future.
+paste() - L<Imager::Transformations/paste> - draw an image onto an image
 
-=item colors
+polygon() - L<Imager::Draw/polygon>
 
-A arrayref containing Imager::Color objects, which represents the
-starting set of colors to use in translating the images.  webmap will
-ignore this.  The final colors used are copied back into this array
-(which is expanded if necessary.)
+polyline() - L<Imager::Draw/polyline>
 
-=item max_colors
+read() - L<Imager::Files>
 
-The maximum number of colors to use in the image.
+read_multi() - L<Imager::Files>
 
-=item translate
+rotate() - L<Imager::Transformations/rotate>
 
-The method used to translate the RGB values in the source image into
-the colors selected by make_colors.  Note that make_colors is ignored
-whene translate is 'giflib'.
+rubthrough() - L<Imager::Transformations/rubthrough> - draw an image onto an
+image and use the alpha channel
 
-Possible values are:
+scale() - L<Imager::Transformations/scale>
 
-=over 4
+setcolors() - L<Imager::ImageTypes> - set palette colors in a paletted image
 
-=item giflib
+setpixel() - L<Imager::Draw/setpixel and getpixel>
 
-The giflib native quantization function is used.
+string() - L<Imager::Font/string> - draw text on an image
 
-=item closest
+tags() -  L<Imager::ImageTypes> - fetch image tags
 
-The closest color available is used.
+to_paletted() -  L<Imager::ImageTypes>
 
-=item perturb
+to_rgb8() - L<Imager::ImageTypes>
 
-The pixel color is modified by perturb, and the closest color is chosen.
+transform() - L<Imager::Engines/"transform">
 
-=item errdiff
+transform2() - L<Imager::Engines/"transform2">
 
-An error diffusion dither is performed.
+type() -  L<Imager::ImageTypes> - type of image (direct vs paletted)
 
-=back
+virtual() - L<Imager::ImageTypes> - whether the image has it's own
+data
 
-It's possible other transate values will be added.
+write() - L<Imager::Files>
 
-=item errdiff
+write_multi() - L<Imager::Files>
 
-The type of error diffusion dither to perform.  These values (except
-for custom) can also be used in tr_errdif.
+=head1 SUPPORT
 
-=over 4
+You can ask for help, report bugs or express your undying love for
+Imager on the Imager-devel mailing list.
 
-=item floyd
+To subscribe send a message with C<subscribe> in the body to:
 
-Floyd-Steinberg dither
+   imager-devel+request@molar.is
 
-=item jarvis
+or use the form at:
 
-Jarvis, Judice and Ninke dither
+   http://www.molar.is/en/lists/imager-devel/
+   (annonymous is temporarily off due to spam)
 
-=item stucki
+where you can also find the mailing list archive.
 
-Stucki dither
+If you're into IRC, you can typically find the developers in #Imager
+on irc.perl.org.  As with any IRC channel, the participants could be
+occupied or asleep, so please be patient.
 
-=item custom
+You can report bugs either by sending email to:
 
-Custom.  If you use this you must also set errdiff_width,
-errdiff_height and errdiff_map.
+  bug-Imager@rt.cpan.org
 
-=back
+or by pointing your browser at:
 
-=item errdiff_width
+  https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Imager
 
-=item errdiff_height
+Please remember to include the versions of Imager, perl, supporting
+libraries, and any relevant code.  If you have specific images that
+cause the problems, please include those too.
 
-=item errdiff_orig
+=head1 BUGS
 
-=item errdiff_map
+Bugs are listed individually for relevant pod pages.
 
-When translate is 'errdiff' and errdiff is 'custom' these define a
-custom error diffusion map.  errdiff_width and errdiff_height define
-the size of the map in the arrayref in errdiff_map.  errdiff_orig is
-an integer which indicates the current pixel position in the top row
-of the map.
+=head1 AUTHOR
 
-=item perturb
+Arnar M. Hrafnkelsson (addi@imager.perl.org) and Tony Cook
+(tony@imager.perl.org) See the README for a complete list.
 
-When translate is 'perturb' this is the magnitude of the random bias
-applied to each channel of the pixel before it is looked up in the
-color table.
+=head1 SEE ALSO
 
-=back
-
-
-
-=head2 Filters
-
-A special image method is the filter method. An example is:
-
-  $img->filter(type=>'autolevels');
-
-This will call the autolevels filter.  Here is a list of the filters
-that are always avaliable in Imager.  This list can be obtained by
-running the C<filterlist.perl> script that comes with the module
-source.
-
-  Filter          Arguments
-  autolevels      lsat(0.1) usat(0.1) skew(0)
-  bumpmap         bump elevation(0) lightx lighty st(2)
-  bumpmap_complex bump channel(0) tx(0) ty(0) Lx(0.2) Ly(0.4)
-                  Lz(-1) cd(1.0) cs(40.0) n(1.3) Ia(0 0 0) Il(255 255 255)
-                  Is(255 255 255)
-  contrast        intensity
-  conv            coef
-  fountain        xa ya xb yb ftype(linear) repeat(none) combine(none)
-                  super_sample(none) ssample_param(4) segments(see below)
-  gaussian        stddev
-  gradgen         xo yo colors dist
-  hardinvert
-  mosaic          size(20)
-  noise           amount(3) subtype(0)
-  postlevels      levels(10)
-  radnoise        xo(100) yo(100) ascale(17.0) rscale(0.02)
-  turbnoise       xo(0.0) yo(0.0) scale(10.0)
-  unsharpmask     stddev(2.0) scale(1.0)
-  watermark       wmark pixdiff(10) tx(0) ty(0)
-
-The default values are in parenthesis.  All parameters must have some
-value but if a parameter has a default value it may be omitted when
-calling the filter function.
-
-The filters are:
-
-=over
-
-=item autolevels
-
-scales the value of each channel so that the values in the image will
-cover the whole possible range for the channel.  I<lsat> and I<usat>
-truncate the range by the specified fraction at the top and bottom of
-the range respectivly..
-
-=item bumpmap
-
-uses the channel I<elevation> image I<bump> as a bumpmap on your
-image, with the light at (I<lightx>, I<lightty>), with a shadow length
-of I<st>.
-
-=item bumpmap_complex
-
-uses the channel I<channel> image I<bump> as a bumpmap on your image.
-If Lz<0 the three L parameters are considered to be the direction of
-the light.  If Lz>0 the L parameters are considered to be the light
-position.  I<Ia> is the ambient colour, I<Il> is the light colour,
-I<Is> is the color of specular highlights.  I<cd> is the diffuse
-coefficient and I<cs> is the specular coefficient.  I<n> is the
-shininess of the surface.
-
-=item contrast
-
-scales each channel by I<intensity>.  Values of I<intensity> < 1.0
-will reduce the contrast.
-
-=item conv
-
-performs 2 1-dimensional convolutions on the image using the values
-from I<coef>.  I<coef> should be have an odd length.
-
-=item fountain
-
-renders a fountain fill, similar to the gradient tool in most paint
-software.  The default fill is a linear fill from opaque black to
-opaque white.  The points A(xa, ya) and B(xb, yb) control the way the
-fill is performed, depending on the ftype parameter:
-
-=over
-
-=item linear
-
-the fill ramps from A through to B.
-
-=item bilinear
-
-the fill ramps in both directions from A, where AB defines the length
-of the gradient.
-
-=item radial
-
-A is the center of a circle, and B is a point on it's circumference.
-The fill ramps from the center out to the circumference.
-
-=item radial_square
-
-A is the center of a square and B is the center of one of it's sides.
-This can be used to rotate the square.  The fill ramps out to the
-edges of the square.
-
-=item revolution
-
-A is the centre of a circle and B is a point on it's circumference.  B
-marks the 0 and 360 point on the circle, with the fill ramping
-clockwise.
-
-=item conical
-
-A is the center of a circle and B is a point on it's circumference.  B
-marks the 0 and point on the circle, with the fill ramping in both
-directions to meet opposite.
-
-=back
-
-The I<repeat> option controls how the fill is repeated for some
-I<ftype>s after it leaves the AB range:
-
-=over
-
-=item none
-
-no repeats, points outside of each range are treated as if they were
-on the extreme end of that range.
-
-=item sawtooth
-
-the fill simply repeats in the positive direction
-
-=item triangle
-
-the fill repeats in reverse and then forward and so on, in the
-positive direction
-
-=item saw_both
-
-the fill repeats in both the positive and negative directions (only
-meaningful for a linear fill).
-
-=item tri_both
-
-as for triangle, but in the negative direction too (only meaningful
-for a linear fill).
-
-=back
-
-By default the fill simply overwrites the whole image (unless you have
-parts of the range 0 through 1 that aren't covered by a segment), if
-any segments of your fill have any transparency, you can set the
-I<combine> option to 'normal' to have the fill combined with the
-existing pixels.  See the description of I<combine> in L<Imager/Fill>.
-
-If your fill has sharp edges, for example between steps if you use
-repeat set to 'triangle', you may see some aliased or ragged edges.
-You can enable super-sampling which will take extra samples within the
-pixel in an attempt anti-alias the fill.
-
-The possible values for the super_sample option are:
-
-=over
-
-=item none
-
-no super-sampling is done
-
-=item grid
-
-a square grid of points are sampled.  The number of points sampled is
-the square of ceil(0.5 + sqrt(ssample_param)).
-
-=item random
-
-a random set of points within the pixel are sampled.  This looks
-pretty bad for low ssample_param values.
-
-=item circle
-
-the points on the radius of a circle within the pixel are sampled.
-This seems to produce the best results, but is fairly slow (for now).
-
-=back
-
-You can control the level of sampling by setting the ssample_param
-option.  This is roughly the number of points sampled, but depends on
-the type of sampling.
-
-The segments option is an arrayref of segments.  You really should use
-the Imager::Fountain class to build your fountain fill.  Each segment
-is an array ref containing:
-
-=over
-
-=item start
-
-a floating point number between 0 and 1, the start of the range of fill parameters covered by this segment.
-
-=item middle
-
-a floating point number between start and end which can be used to
-push the color range towards one end of the segment.
-
-=item end
-
-a floating point number between 0 and 1, the end of the range of fill
-parameters covered by this segment.  This should be greater than
-start.
-
-=item c0
-
-=item c1
-
-The colors at each end of the segment.  These can be either
-Imager::Color or Imager::Color::Float objects.
-
-=item segment type
-
-The type of segment, this controls the way the fill parameter varies
-over the segment. 0 for linear, 1 for curved (unimplemented), 2 for
-sine, 3 for sphere increasing, 4 for sphere decreasing.
-
-=item color type
-
-The way the color varies within the segment, 0 for simple RGB, 1 for
-hue increasing and 2 for hue decreasing.
-
-=back
-
-Don't forget to use Imager::Fountain instead of building your own.
-Really.  It even loads GIMP gradient files.
-
-=item gaussian
-
-performs a gaussian blur of the image, using I<stddev> as the standard
-deviation of the curve used to combine pixels, larger values give
-bigger blurs.  For a definition of Gaussian Blur, see:
-
-  http://www.maths.abdn.ac.uk/~igc/tch/mx4002/notes/node99.html
-
-=item gradgen
-
-renders a gradient, with the given I<colors> at the corresponding
-points (x,y) in I<xo> and I<yo>.  You can specify the way distance is
-measured for color blendeing by setting I<dist> to 0 for Euclidean, 1
-for Euclidean squared, and 2 for Manhattan distance.
-
-=item hardinvert
-
-inverts the image, black to white, white to black.  All channels are
-inverted, including the alpha channel if any.
-
-=item mosaic
-
-produces averaged tiles of the given I<size>.
-
-=item noise
-
-adds noise of the given I<amount> to the image.  If I<subtype> is
-zero, the noise is even to each channel, otherwise noise is added to
-each channel independently.
-
-=item radnoise
-
-renders radiant Perlin turbulent noise.  The centre of the noise is at
-(I<xo>, I<yo>), I<ascale> controls the angular scale of the noise ,
-and I<rscale> the radial scale, higher numbers give more detail.
-
-=item postlevels
-
-alters the image to have only I<levels> distinct level in each
-channel.
-
-=item turbnoise
-
-renders Perlin turbulent noise.  (I<xo>, I<yo>) controls the origin of
-the noise, and I<scale> the scale of the noise, with lower numbers
-giving more detail.
-
-=item unsharpmask
-
-performs an unsharp mask on the image.  This is the result of
-subtracting a gaussian blurred version of the image from the original.
-I<stddev> controls the stddev parameter of the gaussian blur.  Each
-output pixel is: in + I<scale> * (in - blurred).
-
-=item watermark
-
-applies I<wmark> as a watermark on the image with strength I<pixdiff>,
-with an origin at (I<tx>, I<ty>)
-
-=back
-
-A demonstration of most of the filters can be found at:
-
-  http://www.develop-help.com/imager/filters.html
-
-(This is a slow link.)
-
-=head2 Color transformations
-
-You can use the convert method to transform the color space of an
-image using a matrix.  For ease of use some presets are provided.
-
-The convert method can be used to:
-
-=over 4
-
-=item *
-
-convert an RGB or RGBA image to grayscale.
-
-=item *
-
-convert a grayscale image to RGB.
-
-=item *
-
-extract a single channel from an image.
-
-=item *
-
-set a given channel to a particular value (or from another channel)
-
-=back
-
-The currently defined presets are:
-
-=over
-
-=item gray
-
-=item grey
-
-converts an RGBA image into a grayscale image with alpha channel, or
-an RGB image into a grayscale image without an alpha channel.
-
-This weights the RGB channels at 22.2%, 70.7% and 7.1% respectively.
-
-=item noalpha
-
-removes the alpha channel from a 2 or 4 channel image.  An identity
-for other images.
-
-=item red
-
-=item channel0
-
-extracts the first channel of the image into a single channel image
-
-=item green
-
-=item channel1
-
-extracts the second channel of the image into a single channel image
-
-=item blue
-
-=item channel2
-
-extracts the third channel of the image into a single channel image
-
-=item alpha
-
-extracts the alpha channel of the image into a single channel image.
-
-If the image has 1 or 3 channels (assumed to be grayscale of RGB) then
-the resulting image will be all white.
-
-=item rgb
-
-converts a grayscale image to RGB, preserving the alpha channel if any
-
-=item addalpha
-
-adds an alpha channel to a grayscale or RGB image.  Preserves an
-existing alpha channel for a 2 or 4 channel image.
-
-=back
-
-For example, to convert an RGB image into a greyscale image:
-
-  $new = $img->convert(preset=>'grey'); # or gray
-
-or to convert a grayscale image to an RGB image:
-
-  $new = $img->convert(preset=>'rgb');
-
-The presets aren't necessary simple constants in the code, some are
-generated based on the number of channels in the input image.
-
-If you want to perform some other colour transformation, you can use
-the 'matrix' parameter.
-
-For each output pixel the following matrix multiplication is done:
-
-     channel[0]       [ [ $c00, $c01, ...  ]        inchannel[0]
-   [     ...      ] =          ...              x [     ...        ]
-     channel[n-1]       [ $cn0, ...,  $cnn ] ]      inchannel[max]
-                                                          1
-
-So if you want to swap the red and green channels on a 3 channel image:
-
-  $new = $img->convert(matrix=>[ [ 0, 1, 0 ],
-                                 [ 1, 0, 0 ],
-                                 [ 0, 0, 1 ] ]);
-
-or to convert a 3 channel image to greyscale using equal weightings:
-
-  $new = $img->convert(matrix=>[ [ 0.333, 0.333, 0.334 ] ])
-
-=head2 Color Mappings
-
-You can use the map method to map the values of each channel of an
-image independently using a list of lookup tables.  It's important to
-realize that the modification is made inplace.  The function simply
-returns the input image again or undef on failure.
-
-Each channel is mapped independently through a lookup table with 256
-entries.  The elements in the table should not be less than 0 and not
-greater than 255.  If they are out of the 0..255 range they are
-clamped to the range.  If a table does not contain 256 entries it is
-silently ignored.
-
-Single channels can mapped by specifying their name and the mapping
-table.  The channel names are C<red>, C<green>, C<blue>, C<alpha>.
-
-  @map = map { int( $_/2 } 0..255;
-  $img->map( red=>\@map );
-
-It is also possible to specify a single map that is applied to all
-channels, alpha channel included.  For example this applies a gamma
-correction with a gamma of 1.4 to the input image.
-
-  $gamma = 1.4;
-  @map = map { int( 0.5 + 255*($_/255)**$gamma ) } 0..255;
-  $img->map(all=> \@map);
-
-The C<all> map is used as a default channel, if no other map is
-specified for a channel then the C<all> map is used instead.  If we
-had not wanted to apply gamma to the alpha channel we would have used:
-
-  $img->map(all=> \@map, alpha=>[]);
-
-Since C<[]> contains fewer than 256 element the gamma channel is
-unaffected.
-
-It is also possible to simply specify an array of maps that are
-applied to the images in the rgba order.  For example to apply
-maps to the C<red> and C<blue> channels one would use:
-
-  $img->map(maps=>[\@redmap, [], \@bluemap]);
-
-
-
-=head2 Transformations
-
-Another special image method is transform.  It can be used to generate
-warps and rotations and such features.  It can be given the operations
-in postfix notation or the module Affix::Infix2Postfix can be used.
-Look in the test case t/t55trans.t for an example.
-
-transform() needs expressions (or opcodes) that determine the source
-pixel for each target pixel.  Source expressions are infix expressions
-using any of the +, -, *, / or ** binary operators, the - unary
-operator, ( and ) for grouping and the sin() and cos() functions.  The
-target pixel is input as the variables x and y.
-
-You specify the x and y expressions as xexpr and yexpr respectively.
-You can also specify opcodes directly, but that's magic deep enough
-that you can look at the source code.
-
-You can still use the transform() function, but the transform2()
-function is just as fast and is more likely to be enhanced and
-maintained.
-
-Later versions of Imager also support a transform2() class method
-which allows you perform a more general set of operations, rather than
-just specifying a spatial transformation as with the transform()
-method, you can also perform colour transformations, image synthesis
-and image combinations.
-
-transform2() takes an reference to an options hash, and a list of
-images to operate one (this list may be empty):
-
-  my %opts;
-  my @imgs;
-  ...
-  my $img = Imager::transform2(\%opts, @imgs)
-      or die "transform2 failed: $Imager::ERRSTR";
-
-The options hash may define a transformation function, and optionally:
-
-=over 4
-
-=item *
-
-width - the width of the image in pixels.  If this isn't supplied the
-width of the first input image is used.  If there are no input images
-an error occurs.
-
-=item *
-
-height - the height of the image in pixels.  If this isn't supplied
-the height of the first input image is used.  If there are no input
-images an error occurs.
-
-=item *
-
-constants - a reference to hash of constants to define for the
-expression engine.  Some extra constants are defined by Imager
-
-=back
-
-The tranformation function is specified using either the expr or
-rpnexpr member of the options.
-
-=over 4
-
-=item Infix expressions
-
-You can supply infix expressions to transform 2 with the expr keyword.
-
-$opts{expr} = 'return getp1(w-x, h-y)'
-
-The 'expression' supplied follows this general grammar:
-
-   ( identifier '=' expr ';' )* 'return' expr
-
-This allows you to simplify your expressions using variables.
-
-A more complex example might be:
-
-$opts{expr} = 'pix = getp1(x,y); return if(value(pix)>0.8,pix*0.8,pix)'
-
-Currently to use infix expressions you must have the Parse::RecDescent
-module installed (available from CPAN).  There is also what might be a
-significant delay the first time you run the infix expression parser
-due to the compilation of the expression grammar.
-
-=item Postfix expressions
-
-You can supply postfix or reverse-polish notation expressions to
-transform2() through the rpnexpr keyword.
-
-The parser for rpnexpr emulates a stack machine, so operators will
-expect to see their parameters on top of the stack.  A stack machine
-isn't actually used during the image transformation itself.
-
-You can store the value at the top of the stack in a variable called
-foo using !foo and retrieve that value again using @foo.  The !foo
-notation will pop the value from the stack.
-
-An example equivalent to the infix expression above:
-
- $opts{rpnexpr} = 'x y getp1 !pix @pix value 0.8 gt @pix 0.8 * @pix ifp'
-
-=back
-
-transform2() has a fairly rich range of operators.
-
-=over 4
-
-=item +, *, -, /, %, **
-
-multiplication, addition, subtraction, division, remainder and
-exponentiation.  Multiplication, addition and subtraction can be used
-on colour values too - though you need to be careful - adding 2 white
-values together and multiplying by 0.5 will give you grey, not white.
-
-Division by zero (or a small number) just results in a large number.
-Modulo zero (or a small number) results in zero.
-
-=item sin(N), cos(N), atan2(y,x)
-
-Some basic trig functions.  They work in radians, so you can't just
-use the hue values.
-
-=item distance(x1, y1, x2, y2)
-
-Find the distance between two points.  This is handy (along with
-atan2()) for producing circular effects.
-
-=item sqrt(n)
-
-Find the square root.  I haven't had much use for this since adding
-the distance() function.
-
-=item abs(n)
-
-Find the absolute value.
-
-=item getp1(x,y), getp2(x,y), getp3(x, y)
-
-Get the pixel at position (x,y) from the first, second or third image
-respectively.  I may add a getpn() function at some point, but this
-prevents static checking of the instructions against the number of
-images actually passed in.
-
-=item value(c), hue(c), sat(c), hsv(h,s,v)
-
-Separates a colour value into it's value (brightness), hue (colour)
-and saturation elements.  Use hsv() to put them back together (after
-suitable manipulation).
-
-=item red(c), green(c), blue(c), rgb(r,g,b)
-
-Separates a colour value into it's red, green and blue colours.  Use
-rgb(r,g,b) to put it back together.
-
-=item int(n)
-
-Convert a value to an integer.  Uses a C int cast, so it may break on
-large values.
-
-=item if(cond,ntrue,nfalse), if(cond,ctrue,cfalse)
-
-A simple (and inefficient) if function.
-
-=item <=,<,==,>=,>,!=
-
-Relational operators (typically used with if()).  Since we're working
-with floating point values the equalities are 'near equalities' - an
-epsilon value is used.
-
-=item &&, ||, not(n)
-
-Basic logical operators.
-
-=back
-
-A few examples:
-
-=over 4
-
-=item rpnexpr=>'x 25 % 15 * y 35 % 10 * getp1 !pat x y getp1 !pix @pix sat 0.7 gt @pat @pix ifp'
-
-tiles a smaller version of the input image over itself where the
-colour has a saturation over 0.7.
-
-=item rpnexpr=>'x 25 % 15 * y 35 % 10 * getp1 !pat y 360 / !rat x y getp1 1 @rat - pmult @pat @rat pmult padd'
-
-tiles the input image over itself so that at the top of the image the
-full-size image is at full strength and at the bottom the tiling is
-most visible.
-
-=item rpnexpr=>'x y getp1 !pix @pix value 0.96 gt @pix sat 0.1 lt and 128 128 255 rgb @pix ifp'
-
-replace pixels that are white or almost white with a palish blue
-
-=item rpnexpr=>'x 35 % 10 * y 45 % 8 * getp1 !pat x y getp1 !pix @pix sat 0.2 lt @pix value 0.9 gt and @pix @pat @pix value 2 / 0.5 + pmult ifp'
-
-Tiles the input image overitself where the image isn't white or almost
-white.
-
-=item rpnexpr=>'x y 160 180 distance !d y 180 - x 160 - atan2 !a @d 10 / @a + 3.1416 2 * % !a2 @a2 180 * 3.1416 / 1 @a2 sin 1 + 2 / hsv'
-
-Produces a spiral.
-
-=item rpnexpr=>'x y 160 180 distance !d y 180 - x 160 - atan2 !a @d 10 / @a + 3.1416 2 * % !a2 @a 180 * 3.1416 / 1 @a2 sin 1 + 2 / hsv'
-
-A spiral built on top of a colour wheel.
-
-=back
-
-For details on expression parsing see L<Imager::Expr>.  For details on
-the virtual machine used to transform the images, see
-L<Imager::regmach.pod>.
-
-=head2 Matrix Transformations
-
-Rather than having to write code in a little language, you can use a
-matrix to perform transformations, using the matrix_transform()
-method:
-
-  my $im2 = $im->matrix_transform(matrix=>[ -1, 0, $im->getwidth-1,
-                                            0,  1, 0,
-                                            0,  0, 1 ]);
-
-By default the output image will be the same size as the input image,
-but you can supply the xsize and ysize parameters to change the size.
-
-Rather than building matrices by hand you can use the Imager::Matrix2d
-module to build the matrices.  This class has methods to allow you to
-scale, shear, rotate, translate and reflect, and you can combine these
-with an overloaded multiplication operator.
-
-WARNING: the matrix you provide in the matrix operator transforms the
-co-ordinates within the B<destination> image to the co-ordinates
-within the I<source> image.  This can be confusing.
-
-Since Imager has 3 different fairly general ways of transforming an
-image spatially, this method also has a yatf() alias.  Yet Another
-Transformation Function.
-
-=head2 Masked Images
-
-Masked images let you control which pixels are modified in an
-underlying image.  Where the first channel is completely black in the
-mask image, writes to the underlying image are ignored.
-
-For example, given a base image called $img:
-
-  my $mask = Imager->new(xsize=>$img->getwidth, ysize=>getheight,
-                         channels=>1);
-  # ... draw something on the mask
-  my $maskedimg = $img->masked(mask=>$mask);
-
-You can specifiy the region of the underlying image that is masked
-using the left, top, right and bottom options.
-
-If you just want a subset of the image, without masking, just specify
-the region without specifying a mask.
-
-=head2 Plugins
-
-It is possible to add filters to the module without recompiling the
-module itself.  This is done by using DSOs (Dynamic shared object)
-avaliable on most systems.  This way you can maintain our own filters
-and not have to get me to add it, or worse patch every new version of
-the Module.  Modules can be loaded AND UNLOADED at runtime.  This
-means that you can have a server/daemon thingy that can do something
-like:
-
-  load_plugin("dynfilt/dyntest.so")  || die "unable to load plugin\n";
-  %hsh=(a=>35,b=>200,type=>lin_stretch);
-  $img->filter(%hsh);
-  unload_plugin("dynfilt/dyntest.so") || die "unable to load plugin\n";
-  $img->write(type=>'pnm',file=>'testout/t60.jpg')
-    || die "error in write()\n";
-
-Someone decides that the filter is not working as it should -
-dyntest.c modified and recompiled.
-
-  load_plugin("dynfilt/dyntest.so") || die "unable to load plugin\n";
-  $img->filter(%hsh);
-
-An example plugin comes with the module - Please send feedback to
-addi@umich.edu if you test this.
-
-Note: This seems to test ok on the following systems:
-Linux, Solaris, HPUX, OpenBSD, FreeBSD, TRU64/OSF1, AIX.
-If you test this on other systems please let me know.
-
-
-=head1 BUGS
-
-box, arc, circle do not support antialiasing yet.  arc, is only filled
-as of yet.  Some routines do not return $self where they should.  This
-affects code like this, C<$img-E<gt>box()-E<gt>arc()> where an object
-is expected.
-
-When saving Gif images the program does NOT try to shave of extra
-colors if it is possible.  If you specify 128 colors and there are
-only 2 colors used - it will have a 128 colortable anyway.
-
-=head1 AUTHOR
-
-Arnar M. Hrafnkelsson, addi@umich.edu, and recently lots of assistance
-from Tony Cook.  See the README for a complete list.
-
-=head1 SEE ALSO
+perl(1), Imager::ImageTypes(3), Imager::Files(3), Imager::Draw(3),
+Imager::Color(3), Imager::Fill(3), Imager::Font(3),
+Imager::Transformations(3), Imager::Engines(3), Imager::Filters(3),
+Imager::Expr(3), Imager::Matrix2d(3), Imager::Fountain(3)
 
-perl(1), Imager::Color(3), Imager::Font(3), Imager::Matrix2d(3),
-Affix::Infix2Postfix(3), Parse::RecDescent(3) 
-http://www.eecs.umich.edu/~addi/perl/Imager/
+Affix::Infix2Postfix(3), Parse::RecDescent(3)
+http://imager.perl.org/
 
 =cut